Following the instructions in the documentation to redirect HTTP to HTTPS, Traefik doesn't seem to recognize the same hostname on that service.
Here is my traefik.yml:
api:
insecure: true
entryPoints:
web:
address: :80
web-secure:
address: :443
log:
level: ERROR
providers:
docker:
exposedByDefault: false
file:
filename: /etc/traefik/dynamic_config.yml
Here is my dynamic_config.yml:
http:
middlewares:
secureRedirect:
redirectScheme:
scheme: https
tls:
certificates:
- certFile: /etc/ssl/math.crt
keyFile: /etc/ssl/math.key
And here is the relevant portion of docker-compose.yml:
version: '3.7'
services:
##
# Think Through Math
apangea:
build: ./apangea-docker
depends_on:
- postgres
- proxy
- redis
env_file:
- .env
- ./env/app/apangea.env
- ./env/local/redis.env
- ./env/service/auth0.env
- ./env/service/aws.env
- ./env/service/clever.env
- ./env/service/google.env
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
interval: 30s # frequency of health check
retries: 3 # numbe r of times to retry on failure
start_period: 30s # time to wait for the container to bootstrap
timeout: 10s # time allowed for each check to complete
labels:
- traefik.enable=true
- traefik.http.routers.apangea.entryPoints=web
- traefik.http.routers.apangea.middlewares=secureRedirect@file
- traefik.http.routers.apangea.rule=Host(`math.localhost`)
- traefik.http.routers.apangea-secured.entryPoints=web-secure
- treafik.http.routers.apangea-secured.rule=Host(`math.localhost`)
- traefik.http.routers.apangea-secured.tls=true
stdin_open: true
tty: true
volumes:
- ./apangea-docker:/srv/apangea
- ./apangea-docker/public:/srv/apangea/public
- apangea-sync:/srv/apangea:nocopy
- /srv/apangea/public/assets
- type: tmpfs
target: /srv/apangea/tmp/pids/
As you can see, both the apangea
and apangea-secured
routers have a rule=Host(`math.localhost`)
declaration, but Traefik only seems to recognize the first one, as can be seen in the dashboard:
The secure router's hostname is apangea-maestro
instead of math.localhost
as expected. When I enter http://math.localhost
in my browser, it re-routes as expected to https://math.localhost
, but all I see in the browser is 404 page not found
.
What am I missing?