sample.nginx.conf 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Basic server setup for domain "servername.tld"
  2. server {
  3. listen 80;
  4. server_name servername.tld;
  5. root /home/user/www/$host/Public;
  6. index index.html index.php;
  7. # Directives to send expires headers and turn off 404 error logging.
  8. #location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
  9. # expires 24h;
  10. # log_not_found off;
  11. #}
  12. # Route all requests for non-existent files to index.php
  13. location / {
  14. try_files $uri $uri/ /index.php$is_args$args;
  15. }
  16. # Pass PHP scripts to php-fastcgi listening on port 9000
  17. location ~ \.php$ {
  18. # Zero-day exploit defense.
  19. # http://forum.nginx.org/read.php?2,88845,page=3
  20. # Won't work properly (404 error) if the file is not stored on
  21. # this server, which is entirely possible with php-fpm/php-fcgi.
  22. # Comment the 'try_files' line out if you set up php-fpm/php-fcgi
  23. # on another machine. And then cross your fingers that you won't get hacked.
  24. try_files $uri =404;
  25. include fastcgi_params;
  26. fastcgi_pass 127.0.0.1:9000;
  27. }
  28. }
  29. # PHP search for file Exploit:
  30. # The PHP regex location block fires instead of the try_files block. Therefore we need
  31. # to add "try_files $uri =404;" to make sure that "/uploads/virusimage.jpg/hello.php"
  32. # never executes the hidden php code inside virusimage.jpg because it can't find hello.php!
  33. # The exploit also can be stopped by adding "cgi.fix_pathinfo = 0" in your php.ini file.