nginx.conf 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
  21. # deny running scripts inside user folder
  22. location ~* /user/.*\.(txt|md|json|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/php/php7.2-fpm.sock;
  30. # fastcgi_pass unix:/var/run/php5-fpm.sock; #legacy
  31. # fastcgi_pass 127.0.0.1:9000;
  32. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  33. fastcgi_index index.php;
  34. include fastcgi_params;
  35. fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
  36. }
  37. ## End - PHP
  38. }