nginx.conf 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. server {
  2. #listen 80;
  3. index index.html index.php;
  4. ## Begin - Server Info
  5. root /home/USER/www/html;
  6. server_name localhost;
  7. ## End - Server Info
  8. ## Begin - Index
  9. # for subfolders, simply adjust:
  10. # `location /subfolder {`
  11. # and the rewrite to use `/subfolder/index.php`
  12. location / {
  13. try_files $uri $uri/ /index.php?$query_string;
  14. }
  15. ## End - Index
  16. ## Begin - Security
  17. # deny all direct access for these folders
  18. location ~* /(\.git|cache|bin|logs|backup|tests)/.*$ { return 403; }
  19. # deny running scripts inside core system folders
  20. location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
  21. # deny running scripts inside user folder
  22. location ~* /user/.*\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
  23. # deny access to specific files in the root folder
  24. location ~ /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) { return 403; }
  25. ## End - Security
  26. ## Begin - PHP
  27. location ~ \.php$ {
  28. # Choose either a socket or TCP/IP address
  29. fastcgi_pass unix:/var/run/php5-fpm.sock;
  30. # fastcgi_pass 127.0.0.1:9000;
  31. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  32. fastcgi_index index.php;
  33. include fastcgi_params;
  34. fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
  35. }
  36. ## End - PHP
  37. }