server { listen 80; server_name www.example.com; root /www/example.com/public; expires max; ## # Only allow GET, HEAD and POST request methods. By default Nginx blocks # all request types other then GET and HEAD for static content. ## if ($request_method !~ ^(GET|HEAD|POST)$) { return 405; } ## # Pass all .php files onto a php-fpm/php-fcgi server. ## location ~ ^(.*)\.php$ { root /public; # Zero-day exploit defense. # http://forum.nginx.org/read.php?2,88845,page=3 # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi. # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine. And then cross your fingers that you won't get hacked. #try_files $uri =404; try_files /web/example.com$uri =404; #fastcgi_split_path_info ^(.+\.php)(/.+)$; #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini include fastcgi_params; fastcgi_index index.php; fastcgi_pass php; } }