Skip to content

Nginx Reverse Proxy

Nginx runs as a global-mode service (one instance per Swarm node) within the DEV stack (dev_nginx). It handles all incoming HTTPS traffic, terminates SSL, and routes requests to the correct internal service. Despite being in the DEV stack, it serves all environments (DEV, UAT, and Shared) by connecting to all overlay networks.

PropertyValue
Service namedev_nginx
Deploy modeGlobal (1 replica per node)
Ports80 (→ HTTPS redirect), 443 (SSL)
Networksdev_sseris-network, sseris-uat-network, shared_harbor
Configs24+ Docker configs for server blocks
SSL certsMounted from /etc/letsencrypt/live/ayinza.dev/
  1. All *.ayinza.dev DNS records point to Contabo (84.247.134.135)
  2. Nginx on Contabo receives the request, checks the server_name
  3. Routes to the correct internal Docker service via overlay network
  4. DEV services on Azure are reachable through the overlay network

Nginx server blocks are stored as Docker configs, not files on disk. Each domain has its own config.

Terminal window
# List all nginx configs
docker config ls | grep nginx
# Inspect a specific config
docker config inspect <config_name> --pretty
  1. Create the nginx config file with the server block:

    server {
    listen 443 ssl;
    server_name newservice.ayinza.dev;
    ssl_certificate /etc/letsencrypt/live/ayinza.dev/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/ayinza.dev/privkey.pem;
    location / {
    proxy_pass http://service-name:port;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    }
    }
  2. Create a Docker config from the file:

    Terminal window
    docker config create nginx_newservice_conf newservice.conf
  3. Update nginx.yml to reference the new config and mount it in the Nginx service

  4. Redeploy Nginx:

    Terminal window
    docker stack deploy -c /home/kaks/stacks/nginx.yml dev
  5. Verify by visiting https://newservice.ayinza.dev

Located at /home/kaks/stacks/nginx.yml on Azure.