Skip to content

Commit

Permalink
more nginx work for drupal 10
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandermeindl committed Aug 2, 2024
1 parent ae83315 commit aa83dbc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
4 changes: 2 additions & 2 deletions roles/drupal/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ drupal_write_permissions:
- /htdocs/sites/all/translations

# nginx
drupal_with_hotlink_protection: false

# see https://github.com/wodby/nginx/blob/master/templates/presets/drupal8.conf.tmpl
# see https://github.com/wodby/nginx/blob/master/templates/presets/drupal10.conf.tmpl
drupal_nginx_static_files: "css|cur|js|jpe?g|gif|htc|ico|png|xml|otf|ttf|eot|woff|woff2|svg|mp4|svgz|ogg|ogv|pdf|pptx?|zip|tgz|gz|rar|bz2|doc|xls|exe|tar|mid|midi|wav|bmp|rtf|txt|map|webp"
drupal_nginx_files_static: "css|cur|js|jpe?g|gif|htc|ico|png|xml|otf|ttf|eot|woff|woff2|svg|mp4|svgz|ogg|ogv|pdf|pptx?|zip|tgz|gz|rar|bz2|doc|xls|exe|tar|mid|midi|wav|bmp|rtf|txt|map|webp"
drupal_nginx_not_found_regex: "\\.(engine|md|txt|inc|install|make|module|profile|po|sh|.*sql|theme|twig|tpl(\\.php)?|xtmpl|yml|yaml)(~|\\.sw[op]|\\.bak|\\.orig|\\.save)?$|^(\\.(?!well-known).*|Entries.*|Repository|Root|Tag|Template)$|(web\\.config|composer\\.(json|lock)|(package|package-lock)\\.json|yarn\\.lock)$|^#.*#$|\\.php(~|\\.sw[op]|\\.bak|\\.orig|\\.save)$"
drupal_nginx_files_dir_static: 'txt'

# instance wide usage (for /etc/nginx/drupal.conf)
drupal_multilanguage: []
30 changes: 22 additions & 8 deletions roles/drupal/templates/etc/nginx/sites-available/drupal.j2
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,26 @@ server {
{% endfor %}
{% endif %}

# Drupal 7 or higher generated image handling, i.e., imagecache in core. See:
# https://drupal.org/node/371374.
# Drupal 7 or higher generated image handling, i.e., imagecache in core.
# @see https://drupal.org/node/371374.
location ~* /files/(css|js|styles)/ {
{% if drupal_with_hotlink_protection %}
# Image hotlinking protection. If you want hotlinking
# protection for your images uncomment the following line.
include hotlinking_protection.conf;
{% endif %}
expires 1y;
try_files $uri @drupal;
}

location ~* /sites/.+/files/.+\.(?:{{ drupal_nginx_files_dir_static }}) {
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 '';
Expand All @@ -83,17 +91,23 @@ server {
}
}

location ~* /admin/reports/hacked/.+/diff/ {
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_static_files }})$ {
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;

# Set the OS file cache.
open_file_cache max=3000 inactive=120s;
open_file_cache_valid 45s;
Expand Down

0 comments on commit aa83dbc

Please sign in to comment.