Traefik as a reverse proxy
I am moving forward with my setup. The next step before moving the container setup to full public access, is to enable https.
There a different ways of doing that. In the past, I was using nginx
.
I have heard many good things about Traefik so I wanted to give it a try.
Enabling Traefik in compose.yml
I first tried to get all configured using port 80.
This is how it worked-I added the following part to my compose.yml.
traefik:
image: traefik:v2.10
container_name: traefik
command:
- "--api.insecure=true" # Enable Traefik's dashboard (optional)
- "--providers.docker=true" # Enable Docker provider
- "--entrypoints.web.address=:80" # Bind Traefik to port 80
ports:
- "80:80" # Expose Traefik on port 80
- "8080:8080" # Expose Traefik dashboard (optional)
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
restart: unless-stopped
Additionally, I added a label to the web container:
...
labels:
- "traefik.enable=true"
- "traefik.http.routers.web.rule=Host(`public IP`)"
- "traefik.http.services.web.loadbalancer.server.port=5000" container