drupal-ssl.nginxconf 3.9 KB

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