Skip to content

5402: Align nginx image env-var contract#412

Merged
turegjorup merged 5 commits into
feature/update-infrastructure-for-mono-repofrom
feature/5402-align-nginx-env-vars
Apr 29, 2026
Merged

5402: Align nginx image env-var contract#412
turegjorup merged 5 commits into
feature/update-infrastructure-for-mono-repofrom
feature/5402-align-nginx-env-vars

Conversation

@turegjorup

Copy link
Copy Markdown
Contributor

Summary

Finalize the nginx image's operator-facing env-var surface — one name per concept, so the compose side never has to guess what to set.

Variable Before After Purpose
NGINX_FPM_SERVICE host:port combined os2display (host only) upstream hostname
NGINX_FPM_PORT (embedded in NGINX_FPM_SERVICE) 9000 upstream port
NGINX_PORT 8080 8080 listen port (unchanged)
NGINX_MAX_BODY_SIZE 10m 140m upload cap
NGINX_SET_REAL_IP_FROM 172.17.0.0/16 172.16.0.0/12 trusted-proxy CIDR

Why these defaults

  • /16/12 for NGINX_SET_REAL_IP_FROM: covers the full RFC1918 docker bridge range (172.16.0.0172.31.255.255) so multi-network compose stacks don't need to override.
  • 140m upload cap: aligns with the planned PHP_POST_MAX_SIZE ceiling for media uploads. Operators raising one and forgetting the other was a frequent footgun.
  • Splitting NGINX_FPM_SERVICE and NGINX_FPM_PORT: the previous combined host:port value forced operators to embed the port in the hostname env var, which made it impossible to override one without the other and read awkwardly in compose.

Local validation

Built the production nginx image from this branch and verified at runtime:

$ docker run --rm -e NGINX_MAX_BODY_SIZE=200m … cat /etc/nginx/conf.d/default.conf | grep client_max_body_size
    client_max_body_size 200m;

$ docker run --rm -e NGINX_FPM_SERVICE=os2display -e NGINX_FPM_PORT=9000 … head -4 /etc/nginx/conf.d/default.conf
upstream api_backend {
    server os2display:9000;
    keepalive 16;
}

Out of scope

  • The dev compose stack uses its own template under .docker/templates/ and is unaffected. (Unifying dev and prod templates is a separate effort.)

Test plan

  • Build image from this branch; docker run -e NGINX_MAX_BODY_SIZE=200m <image> cat /etc/nginx/conf.d/default.conf | grep client_max_body_size shows 200m.
  • Without overriding the FPM env vars, the rendered upstream block shows server os2display:9000;.
  • No regression in the local dev stack — task compose-up and the dev nginx still serves correctly (separate template).

🤖 Generated with Claude Code

Finalize the nginx image's operator-facing env-var surface so the
compose side has a single name per concept:

  NGINX_FPM_SERVICE=os2display       (host only — was host:port combined)
  NGINX_FPM_PORT=9000                (new — was embedded in NGINX_FPM_SERVICE)
  NGINX_PORT=8080                    (unchanged)
  NGINX_MAX_BODY_SIZE=140m           (was 10m)
  NGINX_SET_REAL_IP_FROM=172.16.0.0/12 (was 172.17.0.0/16)

The /16 → /12 widening covers the full RFC1918 docker bridge range
(172.16-172.31), so multi-network compose stacks no longer need to
override the default. The 140m upload cap matches the planned
PHP_POST_MAX_SIZE / NGINX_MAX_BODY_SIZE alignment for media uploads.

The production template's upstream block now references
${NGINX_FPM_SERVICE}:${NGINX_FPM_PORT} explicitly.

The dev compose stack uses its own template under .docker/templates/
and is unaffected by this change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@turegjorup
turegjorup requested a review from tuj April 29, 2026 09:11
@turegjorup turegjorup self-assigned this Apr 29, 2026
turegjorup and others added 4 commits April 29, 2026 11:16
…r-mono-repo' into feature/5402-align-nginx-env-vars

# Conflicts:
#	CHANGELOG.md
…r-mono-repo' into feature/5402-align-nginx-env-vars

# Conflicts:
#	CHANGELOG.md
#	infrastructure/nginx/Dockerfile
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>
Future nginx config errors now block playwright instead of surfacing as
DNS failures.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@turegjorup
turegjorup merged commit f259227 into feature/update-infrastructure-for-mono-repo Apr 29, 2026
18 checks passed
@turegjorup
turegjorup deleted the feature/5402-align-nginx-env-vars branch April 29, 2026 10:25
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