server { listen 80; # redundant in new nginx versions server_name yourserver.com www.yourserver.com; root /usr/share/nginx/www/drupal; access_log off; fastcgi_param SCRIPT_NAME $fastcgi_script_name; location ~ \..*/.*\.php$ { return 403; } # Block access to "hidden" files and directories whose names begin with a # period. This includes directories used by version control systems such # as Subversion or Git to store control files. location ~ (^|/)\. { return 403; } location / { try_files $uri @rewrite; } location @rewrite { rewrite ^ /index.php; } location ~ \.php$ { set $no_cache ""; if ($request_method !~ ^(GET|HEAD)$) { set $no_cache "1"; } if ($no_cache = "1") { add_header Set-Cookie "_mcnc=1; Max-Age=2; Path=/"; add_header X-Microcachable "0"; } if ($http_cookie ~ SESS) { set $no_cache "1"; } fastcgi_no_cache $no_cache; fastcgi_cache_bypass $no_cache; fastcgi_cache microcache; fastcgi_cache_key $server_name|$request_uri; fastcgi_cache_valid 404 30m; fastcgi_cache_valid 200 1s; fastcgi_max_temp_file_size 1M; fastcgi_cache_use_stale updating; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_pass_header Set-Cookie; fastcgi_pass_header Cookie; fastcgi_ignore_headers Cache-Control Expires Set-Cookie; fastcgi_index index.php; include fastcgi_params; } #Fighting with ImageCache? This little gem is amazing. location ~ ^/sites/.*/files/imagecache/ { try_files $uri @rewrite; } # Catch image styles for D7 too. location ~ ^/sites/.*/files/styles/ { try_files $uri @rewrite; } location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires max; log_not_found off; } }