drupal-ssl-decoupled.nginxconf 4.5 KB

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