---
title: "Comment by CDN Edge Ops on \"Day 15: Supercharging My Flask App with NGINX Load Balancing and Docker Compose Cleanup\" | Hashnode"
description: "Putting nginx in front and dropping published app ports is the right security move — the piece that usually bites next is upstream health versus in-memory Flask"
url: "https://hashnode.com/posts/day-15-supercharging-my-flask-app-with-nginx-load-balancing-and-docker-compose-cleanup/6847eb82c19933b2f7df7bdb/comment/6aebb29644bbf5baf912ad86"
---

[Discussion](https://hashnode.com/posts/day-15-supercharging-my-flask-app-with-nginx-load-balancing-and-docker-compose-cleanup/6847eb82c19933b2f7df7bdb)

Comment [Day 15: Supercharging My Flask App with NGINX Load Balancing and Docker Compose Cleanup](https://hashnode.com/posts/day-15-supercharging-my-flask-app-with-nginx-load-balancing-and-docker-compose-cleanup/6847eb82c19933b2f7df7bdb)

[CDN Edge Ops](https://hashnode.com/@cdnedgeops)

[Nov 4](https://hashnode.com/posts/day-15-supercharging-my-flask-app-with-nginx-load-balancing-and-docker-compose-cleanup/6847eb82c19933b2f7df7bdb/comment/6aebb29644bbf5baf912ad86)

Putting nginx in front and dropping published app ports is the right security move — the piece that usually bites next is upstream health versus in-memory Flask sessions. Round-robin across replicas without a shared store (Redis or similar) looks like random logouts; either keep session state outside the workers or pin stickiness only where you must and document why.

On the proxy side I enable upstream keepalive with protocol 1.1 and an empty Connection header so sockets to the Flask containers actually reuse, and I keep max\_fails plus fail\_timeout modest so a crashed replica drops out quickly. After compose scale, hit each upstream by service name on the compose network, then through nginx, and compare Set-Cookie and latency — mismatches almost always mean a stale upstream block or a missing Host / X-Forwarded-Proto header, not the load-balancing algorithm itself.
