Skip to content

The path of a request ​

On the infrastructure side, what does a request to https://trinity.jostud.com go through?

Step by step ​

  1. DNS: trinity.jostud.com points to the public IP address of the trinity-prod VM.
  2. Firewall: Google Cloud's (trinity-allow-web), then on the VM, only let ports 22, 80 and 443 through. See Infrastructure.
  3. Traefik receives the request. On port 80, it redirects to HTTPS. On port 443, it decrypts with the Let's Encrypt certificate.
  4. Traefik reads the Host(...) rule from its route files and sends the request to http://trinity_web:3000.
  5. trinity_web is the name of the web Swarm service in the trinity stack. Docker resolves it to an internal address, on the trinity network. The service has two tasks: Swarm spreads the requests between them.
  6. The web calls the API at its public address https://api.trinity.jostud.com, which goes back through Traefik.
  7. The API reaches PostgreSQL by the name db, on the internal network, invisible to Traefik.

The two networks ​

NetworkCreated byWho is on itWhy
trinityAnsible (traefik role), overlay --attachableTraefik, web, api, docsTraefik must reach the applications
internaleach Compose fileapi, dbThe database is reachable only by the API

Why an overlay network?

In prod, the applications are Swarm services, while Traefik is a Compose container. An overlay network created with --attachable is the only kind of network both can share.

In dev, it is the same path on the trinity-dev VM, with the Compose containers trinity_web and trinity_api. See Dev and prod environments.