A deploy once sent half of our users to a new app version while the other half still had requests in flight against the old one. Nothing crashed, but a background job started writing data in a format the old version couldn’t read. Blue-green deployments help avoid that kind of surprise: keep two app versions available, then switch traffic only after the new one is ready. This walkthrough shows how to do that with Nginx, including a health check and a rollback.
The setup
We’ll run two copies of an application on one Linux host:
Blue listens on 127.0.0.1:3001
Green listens on 127.0.0.1:3002
Nginx sends traffic to whichever copy is active
The app needs a health endpoint that returns HTTP 200 only when it’s ready to serve requests. For example, /health might check that the process has started and required dependencies are reachable. Adapt the port numbers and health path to your app.
This is a useful pattern for a single host, but it isn’t high availability: if the host fails, both copies go down.…