-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drupal nginx location rewriten from scretch
- Loading branch information
1 parent
8aac9c6
commit da1b90e
Showing
2 changed files
with
171 additions
and
91 deletions.
There are no files selected for viewing
166 changes: 166 additions & 0 deletions
166
roles/drupal/templates/etc/nginx/drupal_locations.inc.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
location = /ads.txt { | ||
try_files $uri @drupal-no-args; | ||
access_log off; | ||
log_not_found off; | ||
} | ||
|
||
location / { | ||
location ~* /system/files/ { | ||
include fastcgi_params; | ||
fastcgi_param QUERY_STRING $query_string; | ||
fastcgi_param SCRIPT_NAME /index.php; | ||
fastcgi_param SCRIPT_FILENAME $document_root/index.php; | ||
fastcgi_pass drupal; | ||
log_not_found off; | ||
} | ||
|
||
location ~* /sites/.+/files/private/ { | ||
internal; | ||
} | ||
|
||
location ~* /files/(css|js|styles)/ { | ||
access_log off; | ||
expires 1y; | ||
try_files $uri @drupal; | ||
} | ||
|
||
location ~* /sites/.+/files/.+\.(?:{{ drupal_nginx_files_dir_static }}) { | ||
access_log off; | ||
expires 1y; | ||
|
||
# No need to bleed constant updates. Send the all shebang in one fell swoop. | ||
tcp_nodelay off; | ||
|
||
# Set the OS file cache. | ||
open_file_cache max=1000 inactive=30s; | ||
open_file_cache_valid 30s; | ||
open_file_cache_min_uses 2; | ||
open_file_cache_errors off; | ||
} | ||
|
||
location ~* /sites/.+/files/optimized/(css|js)/ { | ||
expires max; | ||
add_header ETag ''; | ||
add_header Last-Modified 'Wed, 20 Jan 1988 04:20:42 GMT'; | ||
add_header Accept-Ranges ''; | ||
location ~* /sites/.*/files/optimized/css/.+\.css$ { | ||
access_log off; | ||
add_header Cache-Control "public, max-age=31536000, no-transform, immutable"; | ||
try_files $uri @drupal; | ||
} | ||
location ~* /sites/.*/files/optimized/js/.+\.js$ { | ||
access_log off; | ||
add_header Cache-Control "public, max-age=31536000, no-transform, immutable"; | ||
try_files $uri @drupal; | ||
} | ||
} | ||
|
||
location ~* /admin/reports/hacked/.+/diff/ { | ||
try_files $uri @drupal; | ||
} | ||
|
||
location ~* /rss.xml { | ||
try_files $uri @drupal-no-args; | ||
} | ||
|
||
location ~* /sitemap.xml { | ||
try_files $uri @drupal; | ||
} | ||
|
||
# Replica of regex from Drupals core .htaccess. | ||
location ~* {{ drupal_nginx_not_found_regex }} { | ||
return 404; | ||
} | ||
|
||
# All static files will be served directly. | ||
location ~* ^.+\.(?:{{ drupal_nginx_files_static }})$ { | ||
access_log off; | ||
expires 30d; | ||
|
||
# No need to bleed constant updates. Send the all shebang in one fell swoop. | ||
tcp_nodelay off; | ||
|
||
add_header Pragma "cache"; | ||
add_header Cache-Control "public"; | ||
|
||
# Set the OS file cache. | ||
open_file_cache max=3000 inactive=120s; | ||
open_file_cache_valid 45s; | ||
open_file_cache_min_uses 2; | ||
open_file_cache_errors off; | ||
} | ||
|
||
try_files $uri @drupal; | ||
} | ||
|
||
location @drupal { | ||
include fastcgi_params; | ||
fastcgi_param QUERY_STRING $query_string; | ||
fastcgi_param SCRIPT_NAME /index.php; | ||
fastcgi_param SCRIPT_FILENAME $document_root/index.php; | ||
fastcgi_pass drupal; | ||
} | ||
|
||
location @drupal-no-args { | ||
include fastcgi_params; | ||
fastcgi_param QUERY_STRING q=$uri; | ||
fastcgi_param SCRIPT_NAME /index.php; | ||
fastcgi_param SCRIPT_FILENAME $document_root/index.php; | ||
fastcgi_pass drupal; | ||
} | ||
|
||
location = /index.php { | ||
fastcgi_pass drupal; | ||
} | ||
|
||
location = /core/install.php { | ||
fastcgi_pass drupal; | ||
} | ||
|
||
location = /core/rebuild.php { | ||
fastcgi_pass drupal; | ||
} | ||
|
||
location ~* ^/core/authorize.php { | ||
include fastcgi_params; | ||
fastcgi_param QUERY_STRING $args; | ||
fastcgi_param SCRIPT_NAME /core/authorize.php; | ||
fastcgi_param SCRIPT_FILENAME $document_root/core/authorize.php; | ||
fastcgi_pass drupal; | ||
} | ||
|
||
location = /core/modules/statistics/statistics.php { | ||
fastcgi_pass drupal; | ||
} | ||
|
||
location = /cron { | ||
include fastcgi_params; | ||
fastcgi_param QUERY_STRING $args; | ||
fastcgi_param SCRIPT_NAME /index.php; | ||
fastcgi_param SCRIPT_FILENAME $document_root/index.php; | ||
fastcgi_pass drupal; | ||
} | ||
|
||
location ~* ^/update.php { | ||
include fastcgi_params; | ||
fastcgi_param QUERY_STRING $args; | ||
fastcgi_param SCRIPT_NAME /update.php; | ||
fastcgi_param SCRIPT_FILENAME $document_root/update.php; | ||
fastcgi_pass drupal; | ||
} | ||
|
||
location ^~ /patches { | ||
return 404; | ||
} | ||
|
||
location ^~ /backup { | ||
return 404; | ||
} | ||
|
||
location ~* ^.+\.php$ { | ||
return 404; | ||
} | ||
|
||
location ~ /web.config { | ||
return 404; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters