From cebca54fedb507d311081b3fc8f72e565514ca4d Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Wed, 2 Dec 2026 10:49:06 +0100 Subject: [PATCH] Send only valid Drupal aggregate names to PHP for old sites --- CHANGELOG.md | 4 ++-- .../drupal-8/.docker/templates/default.conf.template | 9 +++++++++ .../drupal-9/.docker/templates/default.conf.template | 9 +++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f92000..a890797 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,6 @@ Changelog", this file is a reverse-chronological list of merged pull requests. ## Open PR's -- [PR-168](https://github.com/itk-dev/devops_itkdev-docker/pull/168) - 2026-11-29 - - Send only valid Drupal aggregate names to PHP. - [PR-135](https://github.com/itk-dev/devops_itkdev-docker/pull/135) - 2026-01-29 - Add Podman support with dynamic machine detection - [PR-126](https://github.com/itk-dev/devops_itkdev-docker/pull/126) - 2026-01-05 - @@ -23,6 +21,8 @@ Changelog", this file is a reverse-chronological list of merged pull requests. ### 2026 +- [PR-168](https://github.com/itk-dev/devops_itkdev-docker/pull/168) - 2026-11-29 - + Send only valid Drupal aggregate names to PHP. - [PR-167](https://github.com/itk-dev/devops_itkdev-docker/pull/167) - 2026-11-26 - Block web access to Drupal's maintenance scripts. - [PR-166](https://github.com/itk-dev/devops_itkdev-docker/pull/166) diff --git a/templates/drupal-8/.docker/templates/default.conf.template b/templates/drupal-8/.docker/templates/default.conf.template index 5ebe43c..f508563 100644 --- a/templates/drupal-8/.docker/templates/default.conf.template +++ b/templates/drupal-8/.docker/templates/default.conf.template @@ -74,6 +74,15 @@ server { return 404; } + # Drupal builds a missing CSS or JS aggregate on each request. Send only + # file names with a valid hash (43 characters) to Drupal. Return 404 for + # other names, for example "css_x.css" in a cache-busting flood. + # Keep these rules after the deny rules above. Nginx uses the first regex + # location that matches. + location ~ "^/sites/[^/]+/files/(css/css_[A-Za-z0-9_-]{43}\.css|js/js_[A-Za-z0-9_-]{43}\.js)$" { + try_files $uri /index.php?$query_string; + } + # Block web access to Drupal's maintenance scripts (update, install, cache # rebuild, and authorize). Use drush and composer for these tasks instead. location ^~ /update.php { diff --git a/templates/drupal-9/.docker/templates/default.conf.template b/templates/drupal-9/.docker/templates/default.conf.template index 5ebe43c..f508563 100644 --- a/templates/drupal-9/.docker/templates/default.conf.template +++ b/templates/drupal-9/.docker/templates/default.conf.template @@ -74,6 +74,15 @@ server { return 404; } + # Drupal builds a missing CSS or JS aggregate on each request. Send only + # file names with a valid hash (43 characters) to Drupal. Return 404 for + # other names, for example "css_x.css" in a cache-busting flood. + # Keep these rules after the deny rules above. Nginx uses the first regex + # location that matches. + location ~ "^/sites/[^/]+/files/(css/css_[A-Za-z0-9_-]{43}\.css|js/js_[A-Za-z0-9_-]{43}\.js)$" { + try_files $uri /index.php?$query_string; + } + # Block web access to Drupal's maintenance scripts (update, install, cache # rebuild, and authorize). Use drush and composer for these tasks instead. location ^~ /update.php {