Skip to content

370: Unify nginx config between dev and prod#409

Merged
turegjorup merged 2 commits into
feature/update-infrastructure-for-mono-repofrom
feature/370-unify-nginx-config
Apr 29, 2026
Merged

370: Unify nginx config between dev and prod#409
turegjorup merged 2 commits into
feature/update-infrastructure-for-mono-repofrom
feature/370-unify-nginx-config

Conversation

@turegjorup

Copy link
Copy Markdown
Contributor

Stacked on #408. Refs #370.

Why

Local dev has historically used its own minimal nginx config under .docker/templates/ and .docker/nginx.conf, while the production image ships a much fuller config under infrastructure/nginx/etc/. The split is exactly what hid the LiipImagineBundle thumbnail 404 (#370) from local testing — dev's location / always wins for everything, so the production-only regex static-file block that broke things never ran locally.

What

  • Parameterize the one prod-template hardcoding that prevented sharing: root /var/www/html/publicroot ${NGINX_WEB_ROOT}.
  • Add NGINX_WEB_ROOT=/var/www/html/public to the production nginx Dockerfile so the deployed image's behavior is unchanged.
  • Update docker-compose.yml and docker-compose.server.yml to mount ./infrastructure/nginx/etc/templates and ./infrastructure/nginx/etc/nginx.conf instead of the dev-only copies, and to set NGINX_WEB_ROOT=/app/public plus NGINX_SET_REAL_IP_FROM=172.16.0.0/12.
  • Delete .docker/templates/default.conf.template and .docker/nginx.conf — single source of truth.

Tradeoff

Dev now inherits production-tuned defaults — rate limiting (limit_req zone=php_limit), immutable cache headers, stricter location matching, security headers. If any of those become a footgun for local iteration, the right fix is to make it env-driven in the shared template (e.g., a NGINX_RATE_LIMIT_BURST knob) rather than to fork the file again.

Test plan

🤖 Generated with Claude Code

Local dev had its own minimal default.conf.template under .docker/,
which lacked the production-only directives (regex static-files
location, rate limiting, /health, security headers). That gap is
exactly what hid the LiipImagineBundle thumbnail 404 from local
testing.

Move all dev compose files to mount the same templates/nginx.conf
shipped in the production nginx image, parameterize the web root via
NGINX_WEB_ROOT (prod default set in the Dockerfile), and delete the
redundant .docker/ copies.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@turegjorup
turegjorup requested a review from tuj April 28, 2026 09:33
@turegjorup turegjorup self-assigned this Apr 28, 2026
Base automatically changed from feature/370-fix-thumbnail-404 to feature/update-infrastructure-for-mono-repo April 28, 2026 11:58
…r-mono-repo' into feature/370-unify-nginx-config

# Conflicts:
#	CHANGELOG.md
@turegjorup
turegjorup merged commit c6057f3 into feature/update-infrastructure-for-mono-repo Apr 29, 2026
18 checks passed
@turegjorup
turegjorup deleted the feature/370-unify-nginx-config branch April 29, 2026 09:07
turegjorup added a commit that referenced this pull request Apr 29, 2026
After PR #409 unified the dev and prod nginx templates, the dev
compose stack also consumes the production template — but it still
passed NGINX_FPM_SERVICE as a combined 'host:port' string. With the
template change in this PR ('server ${NGINX_FPM_SERVICE}:${NGINX_FPM_PORT};'),
that produced a malformed 'display-phpfpm-1:9000:9000' upstream and
nginx failed to start, breaking the Playwright CI run.

Split the value in both docker-compose.yml and docker-compose.server.yml.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants