server {
set $website_host "mywonderfulwebsite.org";
set $website_root "/var/www/mywonderfulwebsite/web";
set $default_controller "index.php";
set $symfony_root "/var/www/mywonderfulwebsite/lib/vendor/symfony";
listen 80;
server_name $website_host;
merge_slashes on;
# Gzip
gzip on;
gzip_min_length 1000;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_disable "MSIE [1-6]\.";
access_log /var/log/nginx/$website_host.access.log;
root $website_root;
index $default_controller;
charset utf-8;
location / {
try_files $uri $uri/ /$default_controller;
}
location /sf {
# path to folder where all symfony assets are located
alias $symfony_root/data/web/sf;
expires max;
}
location /admin {
allow 192.168.0.0/24;
deny all;
}
location ~ \.php$ {
try_files $uri index.php;
fastcgi_pass php-fpm;
fastcgi_index index.php;
fastcgi_intercept_errors on;
fastcgi_read_timeout 600;
fastcgi_send_timeout 600;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param QUERY_STRING $args;
include /etc/nginx/fastcgi_params;
}
### static files
location ~* ^.+\.(jpg|jpeg|gif|png|ico|mp3|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|dat|avi|ppt|txt|tar|mid|midi|wav|bmp|rtf|wmv|mpeg|mpg|tbz|js)$ {
expires max;
valid_referers none blocked server_names
~\.google\. images\.yandex\. ~\.yandex\. ;
if ($invalid_referer) {return 444;}
log_not_found off;
error_page 404 = /404/;
}
}