On my hosting provider I've setup a load balancer that will handle the SSL certificate. I've setup a domain name, api.example.nl that points to that load balancer.
The load balancer is connected to a server running docker swarm and I've setup a traefik container:
services:
traefik:
image: traefik:v3.3.0
hostname: '{{.Node.Hostname}}'
deploy:
placement:
constraints:
- node.role == manager
mode: global
labels:
- traefik.enable=true
- traefik.http.routers.dashboard.rule=Host(`api.example.nl`) && Path(`/traefik`)
- traefik.http.routers.dashboard.service=api@internal
- traefik.http.routers.dashboard.middlewares=auth
- traefik.http.middlewares.auth.basicauth.users=example:$$apr1$$LYLCV6G2$$z9BY.rQzoXsXe/18dEBoq/
- traefik.http.services.dashboard.loadbalancer.server.port=9999
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
ports:
- target: 80
published: 80
protocol: tcp
mode: host
networks:
- traefik_proxy
command:
- --log.level=DEBUG
- --api.dashboard=true
- --accesslog=true
- --providers.swarm.network=traefik_proxy
- --providers.swarm.exposedByDefault=false
- --entrypoints.http.address=:80
networks:
traefik_proxy:
external: true
When I go to https://api.example.nl/traefik it does asks for credentials. When I login, I get a 404 page not found message displayed.
However, when I change
- traefik.http.routers.dashboard.rule=Host(`api.example.nl`) && Path(`/traefik`)
to
- traefik.http.routers.dashboard.rule=Host(`traefik.example.nl`)`
I get the dashboard at traefik.example.nl.
Both subdomains do point to the same IP address of the load balancer and the load balancer has successfully added the SSL certificates from LetsEncrypt.
So why do I get a 404 error with api.example.nl and path /traefik and how do I fix it?