nginx.conf 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. worker_processes 1;
  2. events {
  3. worker_connections 1024;
  4. }
  5. http {
  6. include mime.types;
  7. default_type application/octet-stream;
  8. sendfile on;
  9. keepalive_timeout 65;
  10. server {
  11. listen 80;
  12. server_name localhost;
  13. error_page 500 502 503 504 /50x.html;
  14. location = /50x.html {
  15. root html;
  16. }
  17. location / {
  18. root html;
  19. index index.php;
  20. if (!-e $request_filename){ rewrite ^(.*)$ /index.php last; }
  21. }
  22. # if you want grav in a sub-directory of your main site
  23. # (for example, example.com/mygrav) then you need this rewrite:
  24. location /mygrav {
  25. index index.php;
  26. if (!-e $request_filename){ rewrite ^(.*)$ /mygrav/$2 last; }
  27. try_files $uri $uri/ /index.php?$args;
  28. }
  29. # if using grav in a sub-directory of your site,
  30. # prepend the actual path to each location
  31. # for example: /mygrav/images
  32. # and: /mygrav/user
  33. # and: /mygrav/cache
  34. # and so on
  35. location /images/ {
  36. # Serve images as static
  37. }
  38. location /user {
  39. rewrite ^/user/accounts/(.*)$ /error redirect;
  40. rewrite ^/user/config/(.*)$ /error redirect;
  41. rewrite ^/user/(.*)\.(txt|md|html|php|yaml|json|twig|sh|bat)$ /error redirect;
  42. }
  43. location /cache {
  44. rewrite ^/cache/(.*) /error redirect;
  45. }
  46. location /bin {
  47. rewrite ^/bin/(.*)$ /error redirect;
  48. }
  49. location /backup {
  50. rewrite ^/backup/(.*) /error redirect;
  51. }
  52. location /system {
  53. rewrite ^/system/(.*)\.(txt|md|html|php|yaml|json|twig|sh|bat)$ /error redirect;
  54. }
  55. location /vendor {
  56. rewrite ^/vendor/(.*)\.(txt|md|html|php|yaml|json|twig|sh|bat)$ /error redirect;
  57. }
  58. # Remember to change 127.0.0.1:9000 to the Ip/port
  59. # you configured php-cgi.exe to run from
  60. location ~ \.php$ {
  61. try_files $uri =404;
  62. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  63. fastcgi_pass 127.0.0.1:9000;
  64. fastcgi_index index.php;
  65. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  66. include fastcgi_params;
  67. }
  68. }
  69. }