Skip to main content
Docs/Networking

Networking

VersionGate manages an Nginx upstream file and a dedicated Docker network. Traffic switching is a config rewrite plus reload — never a restart.

Ports and slots

Each environment reserves two host ports: basePort (blue) and basePort + 1 (green). Inside the container your app listens on appPort; Docker maps it to the slot's host port.

Nginx upstream switching

/etc/nginx/conf.d/upstream.conf
upstream myapp {
    server 127.0.0.1:3101;   # rewritten by VersionGate on every switch
}

After a health-checked deploy, VersionGate rewrites the upstream port and runs nginx -s reload. Existing connections drain gracefully; new requests hit the new container.

Docker network

terminal
docker network create versiongate-net

All deployed containers join versiongate-net (configurable via DOCKER_NETWORK), so services can reach each other by container name.

Project custom domains (production)

Each project can attach one production hostname (for example app.example.com). VersionGate writes dedicated nginx files under /etc/nginx/conf.d/ and never overwrites the dashboard vhost in upstream.conf or versiongate.conf.

per-project nginx layout
# upstream — rewritten on every blue/green switch
/etc/nginx/conf.d/vg-app-myapp.upstream.conf

# server — one file per hostname (Certbot-safe)
/etc/nginx/conf.d/vg-app-myapp-app-example-com.conf

Attach from the project page or via POST /api/v1/projects/:id/domains. Point DNS A/AAAA at this server, then run POST .../domains/:domainId/ssl to issue TLS with Certbot (CERTBOT_EMAIL in .env). Until a production deploy is ACTIVE, the upstream uses a down marker and the hostname returns 502/503.

Domains & HTTPS (dashboard)

Settings → Dashboard URL lets you set PUBLIC_DOMAIN and provision certificates via Certbot. Preflight validates DNS resolution, certbot availability, and CERTBOT_EMAIL before attempting issuance.

Hostname opens nowhere, dashboard says working
PM2 online and preflight DNS are measured on the VPS. They do not prove your laptop can resolve the name, or that nginx has a single vhost. Use the domain troubleshooting guide: loopback curls, split-horizon DNS, hairpin NAT, and the three nginx files that overwrite each other after install / Settings / Certbot.

Webhook endpoints

The official VersionGate GitHub App sends webhooks to https://versiongate.tech/api/webhooks/github. The public relay looks up your installation and forwards the event to {PUBLIC_URL}/api/webhooks/github/relay on your VPS (verified with GITHUB_STATE_SECRET). Direct {PUBLIC_URL}/api/webhooks/github remains available for local testing. Legacy per-project webhooks (/api/v1/webhooks/:secret) continue to work without the App.

Behind PM2 with a minimal PATH?
If Docker is installed but PM2 strips your PATH, set DOCKER_BIN=/usr/bin/docker in .env.