Skip to content

feat: include project nginx config from server.d in templates - #163

Open
turegjorup wants to merge 2 commits into
developfrom
feature/nginx-server-overrides
Open

turegjorup wants to merge 2 commits into
developfrom
feature/nginx-server-overrides

Conversation

@turegjorup

@turegjorup turegjorup commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Lets projects keep their own nginx rules in .docker/templates/server.d/ so template:update no longer overwrites them.

Changes

  • templates/{drupal,symfony}/.docker/templates/default.conf.template: include /etc/nginx/conf.d/server.d/*.conf; in the server block (also used by drupal-10, drupal-11, symfony-6, symfony-7 and symfony-8 through symlinks)
  • README.md: where to keep project-specific changes (docker-compose.override.yml, docker-compose.server.override.yml and .docker/templates/server.d/)
  • CHANGELOG.md: add entry

Why

template:update copies the template files over the project's own, so project-specific lines in default.conf.template are lost on every update. For example, event-database-imports serves its admin under /admin and needs a rewrite for its assets. A template update removed that rewrite, and it had to be restored in itk-dev/event-database-imports@2f59b75. The same update removed it again today.

docker compose already has override files for this. nginx now has the same kind of override:

  • The nginx image runs envsubst on *.template files in subfolders of /etc/nginx/templates and writes them to the same subfolder in conf.d. Project files in server.d/ therefore get the same variable substitution as default.conf.template.
  • nginx only loads conf.d/*.conf, not subfolders, so server.d/*.conf is only used through the new include.
  • template:update (rsync without --delete) leaves files the template doesn't ship, so server.d/ survives updates.
  • An include with a wildcard that matches nothing is not an error. Both configs pass nginx -t with no server.d/ folder, so existing projects need no changes.

Tested in event-database-imports with the rewrite moved to .docker/templates/server.d/app-path-prefix.conf.template: admin assets and routes load under /admin (itk-dev/event-database-imports#116).

The EOL drupal-8 and drupal-9 templates are left unchanged.

Drupal and Symfony templates include .docker/templates/server.d/*.conf in the server block, so project-specific nginx rules survive template:update.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant