21/09/2012 6:51am

CSS | Solution - nginx config


# a better nginx config

# author @dnoiz1

server {
root /var/www/mysite.tld/;
server_name mysite.tld www.mysite.tld;

access_log /var/log/nginx/mysite.tld.access.log main;
error_log /var/log/nginx/mysite.tld.error.log;

location ~* ^.+\.(jpg|jpeg|gif|png|css|zip|pdf|txt|js|flv|swf|html|htm)$
{
expires max;
log_not_found off;
try_files $uri $uri/ /framework/main.php?$uri=$args;
}

# dont exec scripts in assets etc
location ~* /assets(.*?)$ { expires max; access_log off; log_not_found off; }

location ~ /\. { deny all; access_log off; log_not_found off; }
location ~* ^.+\.(log|ss|config)$ { deny all; access_log off; log_not_found off; }
location ~* /themes/(.*?)$ { expires max; access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }

if (!-f $request_filename) {
rewrite ^/(.*?)(\?|$)(.*)$ /framework/main.php?url=$1&$3 last;
}

location / {
# buffer sizes can be upped in fastcgi_params
include fastcgi_params;
# a ss site specific worker pool is nice also, using a unix sock instead of localhost tcp
fastcgi_pass unix:/var/run/php-fpm/mysite.tld.sock;
fastcgi_index /index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}


Post Comment