drupal-ssl.nginxconf 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. # https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/
  2. # https://www.howtoforge.com/tutorial/install-letsencrypt-and-secure-nginx-in-debian-9/
  3. server {
  4. listen [::]:80;
  5. server_name DOMAIN.LTD;
  6. return 301 https://$server_name$request_uri;
  7. }
  8. server {
  9. listen [::]:443 ssl;
  10. server_name DOMAIN.LTD;
  11. root /var/www/DOMAIN.LTD/app/web;
  12. #SSL Certificates
  13. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  14. ssl_certificate "/etc/letsencrypt/live/DOMAIN.LTD/fullchain.pem";
  15. ssl_certificate_key "/etc/letsencrypt/live/DOMAIN.LTD/privkey.pem";
  16. ssl_dhparam /etc/nginx/ssl/certs/DOMAIN.LTD/dhparam.pem;
  17. # ssl_session_cache shared:SSL:1m;
  18. ssl_session_timeout 10m;
  19. ssl_ciphers HIGH:!aNULL:!MD5;
  20. #ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
  21. ssl_prefer_server_ciphers on;
  22. add_header Strict-Transport-Security "max-age=31536000;
  23. #includeSubDomains" always;
  24. charset utf-8;
  25. location = /favicon.ico {
  26. access_log off;
  27. log_not_found off;
  28. }
  29. location = /robots.txt {
  30. allow all;
  31. access_log off;
  32. log_not_found off;
  33. }
  34. location ~ \..*/.*\.php$ {
  35. return 403;
  36. }
  37. location ~ ^/sites/.*/private/ {
  38. return 403;
  39. }
  40. # Block access to scripts in site files directory
  41. location ~ ^/sites/[^/]+/files/.*\.php$ {
  42. deny all;
  43. }
  44. # Allow "Well-Known URIs" as per RFC 5785
  45. location ~* ^/.well-known/ {
  46. allow all;
  47. }
  48. # Block access to "hidden" files and directories whose names begin with a
  49. # period. This includes directories used by version control systems such
  50. # as Subversion or Git to store control files.
  51. location ~ (^|/)\. {
  52. return 403;
  53. }
  54. location / {
  55. # try_files $uri @rewrite; # For Drupal <= 6
  56. try_files $uri /index.php?$query_string; # For Drupal >= 7
  57. }
  58. location @rewrite {
  59. rewrite ^/(.*)$ /index.php?q=$1;
  60. }
  61. # Don't allow direct access to PHP files in the vendor directory.
  62. location ~ /vendor/.*\.php$ {
  63. deny all;
  64. return 404;
  65. }
  66. location ~ /\.ht {
  67. deny all;
  68. }
  69. access_log on;
  70. error_log /var/www/DOMAIN.LTD/log/error.log;
  71. sendfile off;
  72. client_max_body_size 100m;
  73. # In Drupal 8, we must also match new paths where the '.php' appears in
  74. # the middle, such as update.php/selection. The rule we use is strict,
  75. # and only allows this pattern with the update.php front controller.
  76. # This allows legacy path aliases in the form of
  77. # blog/index.php/legacy-path to continue to route to Drupal nodes. If
  78. # you do not have any paths like that, then you might prefer to use a
  79. # laxer rule, such as:
  80. # location ~ \.php(/|$) {
  81. # The laxer rule will continue to work if Drupal uses this new URL
  82. # pattern with front controllers other than update.php in a future
  83. # release.
  84. location ~ '\.php$|^/update.php' {
  85. # fastcgi_split_path_info ^(.+\.php)(/.+)$;
  86. fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
  87. include fastcgi.conf;
  88. # Block httpoxy attacks. See https://httpoxy.org/.
  89. fastcgi_param HTTP_PROXY "";
  90. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  91. fastcgi_param PATH_INFO $fastcgi_path_info;
  92. fastcgi_param QUERY_STRING $query_string;
  93. fastcgi_intercept_errors on;
  94. # fastcgi_buffer_size 16k;
  95. # fastcgi_buffers 4 16k;
  96. fastcgi_pass 127.0.0.1:9000;
  97. }
  98. # Fighting with Styles? This little gem is amazing.
  99. # location ~ ^/sites/.*/files/imagecache/ { # For Drupal <= 6
  100. location ~ ^/sites/.*/files/styles/ { # For Drupal >= 7
  101. try_files $uri @rewrite;
  102. }
  103. # Handle private files through Drupal. Private file's path can come
  104. # with a language prefix.
  105. location ~ ^(/[a-z\-]+)?/system/files/ { # For Drupal >= 7
  106. try_files $uri /index.php?$query_string;
  107. }
  108. location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
  109. try_files $uri @rewrite;
  110. expires max;
  111. log_not_found off;
  112. }
  113. # website should not be displayed inside a <frame>, an <iframe> or an <object>
  114. add_header X-Frame-Options SAMEORIGIN;
  115. }