The path of a request
On the infrastructure side, what does a request to https://trinity.jostud.com go through?
Step by step
- DNS:
trinity.jostud.compoints to the public IP address of thetrinity-prodVM. - Firewall: Google Cloud's (
trinity-allow-web), then on the VM, only let ports 22, 80 and 443 through. See Infrastructure. - Traefik receives the request. On port 80, it redirects to HTTPS. On port 443, it decrypts with the Let's Encrypt certificate.
- Traefik reads the
Host(...)rule from its route files and sends the request tohttp://trinity_web:3000. trinity_webis the name of thewebSwarm service in thetrinitystack. Docker resolves it to an internal address, on thetrinitynetwork. The service has two tasks: Swarm spreads the requests between them.- The web calls the API at its public address
https://api.trinity.jostud.com, which goes back through Traefik. - The API reaches PostgreSQL by the name
db, on theinternalnetwork, invisible to Traefik.
The two networks
| Network | Created by | Who is on it | Why |
|---|---|---|---|
trinity | Ansible (traefik role), overlay --attachable | Traefik, web, api, docs | Traefik must reach the applications |
internal | each Compose file | api, db | The 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.