Application deployment boundaries
A request boundary is a trust boundary
Only Nginx is intended to receive lab client requests. Both app listeners are loopback-only. For a real single-edge proxy replace client-supplied forwarding values with trusted observations. If another authorized proxy sits in front, use its verified trust policy instead; loopback alone is not protection against other untrusted local processes. The app must trust only the known proxy and ignore unrecognized forwarding or identity headers.
Forward the minimum contract
proxy_http_version 1.1;proxy_set_header Host app.test;proxy_set_header X-Forwarded-For $remote_addr;proxy_set_header X-Forwarded-Proto $scheme;proxy_set_header Forwarded "";proxy_cache off;Fixed Host prevents arbitrary client host values from driving the toy app. Empty Forwarded suppresses that request field. A production app may need allowlisted external host, forwarded port and trusted proxy configuration; test its URL generation. These apps do not consume forwarded headers. In Express verify trust proxy settings; in Gunicorn and Uvicorn verify forwarded-allow-ips and relevant header handling. Do not trust all addresses as a shortcut. WebSocket upgrade is a separate protocol-specific route covered next.
Process supervision and readiness
An application process supervisor manages startup, restart limits, service identity, resource bounds, logs and graceful termination. Nginx reload is not a Node or Python restart. Run background jobs in their own worker process, not in Nginx or in every HTTP worker by accident. Readiness is an application assertion that it can serve traffic now; liveness is about whether a process is alive. A simple ready marker does not test a real database or queue.
node node_app.cjs# In another terminal:python3 wsgi_app.py# In a third terminal, after preparing run/ and checking ports:nginx -p "$PWD/" -c nginx.conf -tnginx -p "$PWD/" -c nginx.confThe complete lab README describes isolation and cleanup. Do not run these commands against a system configuration. In production, use a maintained application server, a reviewed supervisor and a distinct service account.
Verify before sending traffic
curl --fail --max-time 3 http://127.0.0.1:19030/healthcurl --fail --max-time 3 http://127.0.0.1:19031/healthcurl --fail --max-time 3 -H "Host: app.test" http://127.0.0.1:18300/api/itemscurl --fail --max-time 3 -H "Host: app.test" http://127.0.0.1:18300/server/reportsCheck the backend directly, then the proxy. A backend connection failure can produce 502; a timeout waiting for the upstream can produce 504. An application-generated 404 is not a proxy transport failure. Inspect sanitized access logs and upstream status to separate these cases. No query secrets or authentication headers are logged in the fixture.
Plan a safe release
1. Build reviewed artifacts; retain previous version.2. Start new private backend; check readiness.3. Test proposed Nginx configuration and route matrix.4. Reload the lab proxy only; verify served version and errors.5. Drain old connections before stopping the old backend.6. Roll back routing if checks fail; handle data migrations separately.A reload is graceful but does not guarantee no interruptions, especially with long-lived streams or application changes. Keep the prior app available until verification finishes. Do not roll back database changes blindly. Practice: write a release checklist for two app processes, and specify which failure triggers rollback.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Application deployment boundaries
Design a deployment boundary with controlled headers, independent process supervision and readiness verification.
Which operation restarts a Python application process?
Which incoming forwarding policy is suitable for the single-edge fixture?
What should you verify before directing traffic to a new backend?
Which response may indicate a refused upstream connection?
What should happen to the previous backend during release verification?