Skip to content

Instantly share code, notes, and snippets.

@sfelde
Created February 1, 2014 13:10
Show Gist options
  • Save sfelde/8752195 to your computer and use it in GitHub Desktop.
Save sfelde/8752195 to your computer and use it in GitHub Desktop.
nginx-typo3
server {
# listen 80; ## listen for ipv4; this line is default and implied
root /srv/dlf;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name _;
location = /favicon.ico {
log_not_found off;
access_log off;
expires max;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location ~* \.(jpg|jpeg|png|gif|css|js|ico)$ {
expires max;
log_not_found off;
}
location ~* \.(cur|ico|gif|png|jpe?g|css|js|swf|woff)((\?\d\d\d\d\d\d\d\d\d\d)|(\?s=\d\d\d\d\d\d\d\d\d\d))$ {
expires max;
log_not_found off;
}
location ~* \.(cur|ico|gif|png|jpe?g|css|js|swf|woff)(\?v\d\d?\.\d\d?\.\d\d?)$ {
expires max;
log_not_found off;
}
location ~* ^(/typo3/sysext|/typo3conf/ext).*\.(cur|ico|gif|png|jpe?g|css|js|swf|woff) {
expires max;
log_not_found off;
}
location = /clear.gif {
empty_gif;
expires max;
}
location ^~ /typo3/gfx {
expires max;
}
location ^~ /typo3temp/compressor {
expires max;
}
location ~* \.(sql|htaccess|htpasswd|tpl|html5|xhtml) {
deny all;
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
#try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
if ($query_string ~ ".+") {
return 405;
}
# pass requests from logged-in users to PHP
if ($http_cookie ~ 'nc_staticfilecache|be_typo_user' ) {
return 405;
} # pass POST requests to PHP
if ($request_method !~ ^(GET|HEAD)$ ) {
return 405;
}
if ($http_pragma = 'no-cache') {
return 405;
}
if ($http_cache_control = 'no-cache') {
return 405;
}
error_page 405 = @nocache;
# serve requested content from the cache if available, otherwise pass the request to PHP
try_files /typo3temp/tx_ncstaticfilecache/$host${request_uri}index.html @nocache;
}
location @nocache {
try_files $uri $uri/ /index.php?$args;
}
location ^~ /typo3temp/tx_ncstaticfilecache {
expires 43200;
charset utf-8;
}
#location /doc/ {
# alias /usr/share/doc/;
# autoindex on;
# allow 127.0.0.1;
# deny all;
#}
# Only for nginx-naxsi : process denied requests
#location /RequestDenied {
# For example, return an error code
#return 418;
#}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/www;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment