Advertisement
maverick78

example.com vhost config nginx

Mar 21st, 2012
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. server {
  2. listen 80;
  3. server_name www.example.com;
  4. root /www/example.com/public;
  5.  
  6. expires max;
  7.  
  8. ##
  9. # Only allow GET, HEAD and POST request methods. By default Nginx blocks
  10. # all request types other then GET and HEAD for static content.
  11. ##
  12.  
  13. if ($request_method !~ ^(GET|HEAD|POST)$) {
  14. return 405;
  15. }
  16.  
  17. ##
  18. # Pass all .php files onto a php-fpm/php-fcgi server.
  19. ##
  20.  
  21. location ~ ^(.*)\.php$ {
  22.  
  23. root /public;
  24.  
  25. # Zero-day exploit defense.
  26. # http://forum.nginx.org/read.php?2,88845,page=3
  27. # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
  28. # 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.
  29. #try_files $uri =404;
  30. try_files /web/example.com$uri =404;
  31.  
  32. #fastcgi_split_path_info ^(.+\.php)(/.+)$;
  33. #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
  34.  
  35.  
  36. include fastcgi_params;
  37. fastcgi_index index.php;
  38.  
  39. fastcgi_pass php;
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement