1- # @see https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/
21server {
32 listen 80;
43 server_name localhost;
@@ -16,9 +15,7 @@ server {
1615 access_log off;
1716 }
1817
19- # Very rarely should these ever be accessed outside of your lan
2018 location ~* \.(txt|log)$ {
21- allow 192.168.0.0/16;
2219 deny all;
2320 }
2421
@@ -30,56 +27,31 @@ server {
3027 return 403;
3128 }
3229
33- # Block access to scripts in site files directory
3430 location ~ ^/sites/[^/]+/files/.*\.php$ {
3531 deny all;
3632 }
3733
38- # Allow "Well-Known URIs" as per RFC 5785
39- location ~* ^/.well-known/ {
40- allow all;
41- }
42-
43- # Block access to "hidden" files and directories whose names begin with a
44- # period. This includes directories used by version control systems such
45- # as Subversion or Git to store control files.
4634 location ~ (^|/)\. {
4735 return 403;
4836 }
4937
5038 location / {
51- # try_files $uri @rewrite; # For Drupal <= 6
52- try_files $uri /index.php?$query_string; # For Drupal >= 7
39+ try_files $uri /index.php?$query_string;
5340 }
5441
5542 location @rewrite {
5643 rewrite ^/(.*)$ /index.php?q=$1;
5744 }
5845
59- # Don't allow direct access to PHP files in the vendor directory.
6046 location ~ /vendor/.*\.php$ {
6147 deny all;
6248 return 404;
6349 }
6450
65- # In Drupal 8, we must also match new paths where the '.php' appears in
66- # the middle, such as update.php/selection. The rule we use is strict,
67- # and only allows this pattern with the update.php front controller.
68- # This allows legacy path aliases in the form of
69- # blog/index.php/legacy-path to continue to route to Drupal nodes. If
70- # you do not have any paths like that, then you might prefer to use a
71- # laxer rule, such as:
72- # location ~ \.php(/|$) {
73- # The laxer rule will continue to work if Drupal uses this new URL
74- # pattern with front controllers other than update.php in a future
75- # release.
7651 location ~ '\.php$|^/update.php' {
7752 fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
78- # Security note: If you're running a version of PHP older than the
79- # latest 5.3, you should have "cgi.fix_pathinfo = 0;" in php.ini.
80- # See http://serverfault.com/q/627903/94922 for details.
8153 include fastcgi_params;
82- # Block httpoxy attacks. See https://httpoxy.org/.
54+
8355 fastcgi_param HTTP_PROXY "";
8456 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
8557 fastcgi_param PATH_INFO $fastcgi_path_info;
@@ -88,15 +60,11 @@ server {
8860 fastcgi_pass phpfpm:9000;
8961 }
9062
91- # Fighting with Styles? This little gem is amazing.
92- # location ~ ^/sites/.*/files/imagecache/ { # For Drupal <= 6
93- location ~ ^/sites/.*/files/styles/ { # For Drupal >= 7
63+ location ~ ^/sites/.*/files/styles/ {
9464 try_files $uri @rewrite;
9565 }
9666
97- # Handle private files through Drupal. Private file's path can come
98- # with a language prefix.
99- location ~ ^(/[a-z\-]+)?/system/files/ { # For Drupal >= 7
67+ location ~ ^(/[a-z\-]+)?/system/files/ {
10068 try_files $uri /index.php?$query_string;
10169 }
10270
0 commit comments