infrastructure/projects/traefik
Chuck Adams aeb420ea2c
Serve long-lived certs (expiring 2027) for *.aspiredev.org (#7)
* refactor: move traefik management port to docker-compose.override.yml

* feat: convert traefik to file based config, use static cert
2025-02-25 10:51:20 -07:00
..
bin Serve long-lived certs (expiring 2027) for *.aspiredev.org (#7) 2025-02-25 10:51:20 -07:00
certs Serve long-lived certs (expiring 2027) for *.aspiredev.org (#7) 2025-02-25 10:51:20 -07:00
certs.available Serve long-lived certs (expiring 2027) for *.aspiredev.org (#7) 2025-02-25 10:51:20 -07:00
traefik-config.d Serve long-lived certs (expiring 2027) for *.aspiredev.org (#7) 2025-02-25 10:51:20 -07:00
docker-compose.override.dist.yml Serve long-lived certs (expiring 2027) for *.aspiredev.org (#7) 2025-02-25 10:51:20 -07:00
docker-compose.yml Serve long-lived certs (expiring 2027) for *.aspiredev.org (#7) 2025-02-25 10:51:20 -07:00
README.md Serve long-lived certs (expiring 2027) for *.aspiredev.org (#7) 2025-02-25 10:51:20 -07:00
traefik.yaml Serve long-lived certs (expiring 2027) for *.aspiredev.org (#7) 2025-02-25 10:51:20 -07:00

Docker Network Proxy

Quick Start

bin/up
echo "127.0.0.1 api.aspiredev.org staging.aspiredev.org" | sudo tee -a /etc/hosts
echo "::1       api.aspiredev.org staging.aspiredev.org" | sudo tee -a /etc/hosts

(Windows users, including WSL2: edit C:\Windows\System32\drivers\etc\hosts instead of /etc/hosts)

HOWTO: self-signed certs that pass validation

brew install mkcert     # also available on most other package managers
mkcert -install
mkcert -cert-file certs/aspiredev.crt -key-file certs/aspiredev.key "*.aspiredev.org"

Enabling the proxy in docker-compose.yml

Add the following to the service you want proxied, substituting myservice and myhostname.local appropriately

myservice can be anything you want, but it must be unique across all your docker containers

labels:
  - "traefik.enable=true"
  - "traefik.http.routers.myservice.rule=Host(`myhostname.local`)"
  - "traefik.http.routers.myservice-https.rule=Host(`myhostname.local`)"
  - "traefik.http.routers.myservice-https.tls=true"
networks:
  - traefik

Add the following to the top level keys

networks:
  traefik:
    external: true

Finally, add the following lines to your /etc/hosts file (C:\Windows\System32\drivers\etc\hosts on Windows)

127.0.0.1 myhostname.local 
::1       myhostname.local