From 2d6f802713bc9536abb1d14c98ec3972abaf018d Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 26 Nov 2026 10:32:44 +0100 Subject: [PATCH 1/2] Block web access to Drupal's maintenance scripts (update, install, cache rebuild, and authorize) --- CHANGELOG.md | 2 ++ .../drupal-8/.docker/templates/default.conf.template | 8 +++++++- .../drupal-9/.docker/templates/default.conf.template | 8 +++++++- templates/drupal/.docker/templates/default.conf.template | 8 +++++++- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 739b6c74..55524601 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ Changelog", this file is a reverse-chronological list of merged pull requests. ## Open PR's +- [PR-167](https://github.com/itk-dev/devops_itkdev-docker/pull/167) - 2026-11-26 - + Block web access to Drupal's maintenance scripts. - [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 - diff --git a/templates/drupal-8/.docker/templates/default.conf.template b/templates/drupal-8/.docker/templates/default.conf.template index 8ff4314c..ad1775e2 100644 --- a/templates/drupal-8/.docker/templates/default.conf.template +++ b/templates/drupal-8/.docker/templates/default.conf.template @@ -74,7 +74,13 @@ server { return 404; } - location ~ '\.php$|^/update.php' { + # 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|install\.php|core/(install|rebuild|authorize)\.php)(/|$) { + return 404; + } + + location ~ '\.php$' { include fastcgi_params; fastcgi_buffers 16 32k; diff --git a/templates/drupal-9/.docker/templates/default.conf.template b/templates/drupal-9/.docker/templates/default.conf.template index 8ff4314c..ad1775e2 100644 --- a/templates/drupal-9/.docker/templates/default.conf.template +++ b/templates/drupal-9/.docker/templates/default.conf.template @@ -74,7 +74,13 @@ server { return 404; } - location ~ '\.php$|^/update.php' { + # 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|install\.php|core/(install|rebuild|authorize)\.php)(/|$) { + return 404; + } + + location ~ '\.php$' { include fastcgi_params; fastcgi_buffers 16 32k; diff --git a/templates/drupal/.docker/templates/default.conf.template b/templates/drupal/.docker/templates/default.conf.template index e77213bd..5165760c 100644 --- a/templates/drupal/.docker/templates/default.conf.template +++ b/templates/drupal/.docker/templates/default.conf.template @@ -74,7 +74,13 @@ server { return 404; } - location ~ '\.php$|^/update.php' { + # 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|install\.php|core/(install|rebuild|authorize)\.php)(/|$) { + return 404; + } + + location ~ '\.php$' { include fastcgi_params; fastcgi_buffers 16 32k; From a31a323ac44cdfc3cad3fe19174e1783c6ea7a51 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Thu, 26 Nov 2026 10:54:46 +0100 Subject: [PATCH 2/2] Updated to not use regex for blocking --- .../.docker/templates/default.conf.template | 18 +++++++++++++++++- .../.docker/templates/default.conf.template | 18 +++++++++++++++++- .../.docker/templates/default.conf.template | 18 +++++++++++++++++- 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/templates/drupal-8/.docker/templates/default.conf.template b/templates/drupal-8/.docker/templates/default.conf.template index ad1775e2..5ebe43c9 100644 --- a/templates/drupal-8/.docker/templates/default.conf.template +++ b/templates/drupal-8/.docker/templates/default.conf.template @@ -76,7 +76,23 @@ server { # 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|install\.php|core/(install|rebuild|authorize)\.php)(/|$) { + location ^~ /update.php { + return 404; + } + + location ^~ /install.php { + return 404; + } + + location ^~ /core/install.php { + return 404; + } + + location ^~ /core/rebuild.php { + return 404; + } + + location ^~ /core/authorize.php { return 404; } diff --git a/templates/drupal-9/.docker/templates/default.conf.template b/templates/drupal-9/.docker/templates/default.conf.template index ad1775e2..5ebe43c9 100644 --- a/templates/drupal-9/.docker/templates/default.conf.template +++ b/templates/drupal-9/.docker/templates/default.conf.template @@ -76,7 +76,23 @@ server { # 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|install\.php|core/(install|rebuild|authorize)\.php)(/|$) { + location ^~ /update.php { + return 404; + } + + location ^~ /install.php { + return 404; + } + + location ^~ /core/install.php { + return 404; + } + + location ^~ /core/rebuild.php { + return 404; + } + + location ^~ /core/authorize.php { return 404; } diff --git a/templates/drupal/.docker/templates/default.conf.template b/templates/drupal/.docker/templates/default.conf.template index 5165760c..451bd598 100644 --- a/templates/drupal/.docker/templates/default.conf.template +++ b/templates/drupal/.docker/templates/default.conf.template @@ -76,7 +76,23 @@ server { # 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|install\.php|core/(install|rebuild|authorize)\.php)(/|$) { + location ^~ /update.php { + return 404; + } + + location ^~ /install.php { + return 404; + } + + location ^~ /core/install.php { + return 404; + } + + location ^~ /core/rebuild.php { + return 404; + } + + location ^~ /core/authorize.php { return 404; }