nginx-ddev-site.conf 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. # ddev GravCMS config
  2. # You can override ddev's configuration by placing an edited copy
  3. # of this config (or one of the other ones) in .ddev/nginx-site.conf
  4. # See https://ddev.readthedocs.io/en/stable/users/extend/customization-extendibility/#providing-custom-nginx-configuration
  5. # Set https to 'on' if x-forwarded-proto is https
  6. map $http_x_forwarded_proto $fcgi_https {
  7. default off;
  8. https on;
  9. }
  10. server {
  11. listen 80;
  12. listen [::]:80 default ipv6only=on;
  13. # The WEBSERVER_DOCROOT variable is substituted with
  14. # its value when the container is started.
  15. root $WEBSERVER_DOCROOT;
  16. include /etc/nginx/monitoring.conf;
  17. index index.php index.htm index.html;
  18. # Make site accessible from http://localhost/
  19. server_name _;
  20. # Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
  21. sendfile off;
  22. error_log /dev/stdout info;
  23. access_log /var/log/nginx/access.log;
  24. ## Begin - Index
  25. # for subfolders, simply adjust:
  26. # `location /subfolder {`
  27. # and the rewrite to use `/subfolder/index.php`
  28. location / {
  29. try_files $uri $uri/ /index.php?$query_string;
  30. }
  31. ## End - Index
  32. # pass the PHP scripts to FastCGI server listening on socket
  33. location ~ \.php$ {
  34. try_files $uri =404;
  35. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  36. fastcgi_pass unix:/run/php-fpm.sock;
  37. fastcgi_buffers 16 16k;
  38. fastcgi_buffer_size 32k;
  39. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  40. fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  41. fastcgi_index index.php;
  42. include fastcgi_params;
  43. fastcgi_intercept_errors off;
  44. # fastcgi_read_timeout should match max_execution_time in php.ini
  45. fastcgi_read_timeout 10m;
  46. fastcgi_param SERVER_NAME $host;
  47. fastcgi_param HTTPS $fcgi_https;
  48. }
  49. ## Begin - Security
  50. # deny all direct access for these folders
  51. location ~* /(\.git|cache|bin|logs|backup|tests)/.*$ { return 403; }
  52. # deny running scripts inside core system folders
  53. location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
  54. # deny running scripts inside user folder
  55. location ~* /user/.*\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
  56. # deny access to specific files in the root folder
  57. location ~ /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) { return 403; }
  58. ## End - Security
  59. include /mnt/ddev_config/nginx/*.conf;
  60. }
  61. server {
  62. listen 443 ssl;
  63. listen [::]:443 default ipv6only=on;
  64. # The WEBSERVER_DOCROOT variable is substituted with
  65. # its value when the container is started.
  66. root $WEBSERVER_DOCROOT;
  67. ssl_certificate /etc/ssl/certs/master.crt;
  68. ssl_certificate_key /etc/ssl/certs/master.key;
  69. include /etc/nginx/monitoring.conf;
  70. index index.php index.htm index.html;
  71. # Make site accessible from http://localhost/
  72. server_name _;
  73. # Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
  74. sendfile off;
  75. error_log /dev/stdout info;
  76. access_log /var/log/nginx/access.log;
  77. ## Begin - Index
  78. # for subfolders, simply adjust:
  79. # `location /subfolder {`
  80. # and the rewrite to use `/subfolder/index.php`
  81. location / {
  82. try_files $uri $uri/ /index.php?$query_string;
  83. }
  84. ## End - Index
  85. # pass the PHP scripts to FastCGI server listening on socket
  86. location ~ \.php$ {
  87. try_files $uri =404;
  88. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  89. fastcgi_pass unix:/run/php-fpm.sock;
  90. fastcgi_buffers 16 16k;
  91. fastcgi_buffer_size 32k;
  92. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  93. fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  94. fastcgi_index index.php;
  95. include fastcgi_params;
  96. fastcgi_intercept_errors off;
  97. # fastcgi_read_timeout should match max_execution_time in php.ini
  98. fastcgi_read_timeout 10m;
  99. fastcgi_param SERVER_NAME $host;
  100. fastcgi_param HTTPS $fcgi_https;
  101. }
  102. ## Begin - Security
  103. # deny all direct access for these folders
  104. location ~* /(\.git|cache|bin|logs|backup|tests)/.*$ { return 403; }
  105. # deny running scripts inside core system folders
  106. location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
  107. # deny running scripts inside user folder
  108. location ~* /user/.*\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
  109. # deny access to specific files in the root folder
  110. location ~ /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) { return 403; }
  111. ## End - Security
  112. include /mnt/ddev_config/nginx/*.conf;
  113. }