Nginx

Set Up Nginx as a Reverse Proxy for Docker

Route domains to your containers

Configure Nginx as a reverse proxy to route your domains to different Docker containers.

Table of contents
  1. 1 Nginx configuration
  2. 2 Reload

We will use Nginx to route each subdomain to a different container on the same server.

Nginx configuration

server {
    listen 80;
    server_name app.example.com;
    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $remote_addr;
    }
}

Reload

sudo nginx -t
sudo systemctl reload nginx
Done

Open the domain in your browser and confirm the app loads.

Was this tutorial helpful?

88% found this helpful.

Comments 0

No comments yet. Be the first to comment.

Leave a comment

Your email is never published.

Related tutorials