I am setting up a test environment with traefik v2.2 in docker. I setup a docker network named traefik, with a test web container. I can see my dashboard if I navigate to https://test.com, however I cannot see my container when I navigate to the paths as setup by the rules (i.e. https://test.com/myapp)
In the dashboard, everything looks ok in status, the myapp container's internal ip shows up, the routers and https entrypoint are fine.
If I go to https://test.com/myapp it gives an customized 404 page "Error code explanation: 404 = Nothing matches the given URI. " If I go to https://test.com/somenonexistantpath it gives me a regular 404 not found message
I have tried changing the Host rules. I added traefik.docker.network=traefik to the container labels in case they were not on the same network as the traefik container, and verified I could reach http://myapp:80 from inside the traefik container. The host rule looks correct according to the traefik v2 documentation, so I am wondering if I am missing anything.
I did test out moving the test.com Host rule to myapp and that was able to reach the test site, so it seems like I am missing something with paths
Below is my docker-compose file, the config file dynamic-traefik.yaml only has the tls info
version: '3.3'
networks:
traefik:
external: true
services:
traefik:
image: traefik:v2.2 #latest pull as of Feb 25, 2020
container_name: traefik
restart: always
networks:
- traefik
ports:
- "443:443"
volumes:
- ${PWD}/traefik:/traefik # Traefik static config
- /var/run/docker.sock:/var/run/docker.sock:ro # SSL Development certificates
command:
- "--log.level=DEBUG"
#- "--accesslog=true"
- "--api=true"
- "--api.dashboard=true"
- "--api.debug=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.network=traefik"
- "--providers.docker.endpoint=unix:///var/run/docker.sock"
- "--providers.docker.watch=true"
- "--entrypoints.https.address=:443"
# apparently you still neeed an extra file to specify TLS
- "--providers.file.filename=/traefik/dynamic-traefik.yaml"
labels:
- "traefik.enable=true"
# Traefik Dashboard
- "traefik.http.routers.traefik.rule=Host(`test.com`)" #works but only gives you dashboard
- "traefik.http.routers.traefik.service=api@internal"
- "traefik.http.routers.traefik.entrypoints=https"
- "traefik.http.routers.traefik.tls=true"
- "traefik.docker.network=traefik"
myapp:
image: yeasy/simple-web:latest
container_name: myapp
restart: always
networks:
- traefik
labels:
- "traefik.enable=true"
- "traefik.http.routers.myapp.entrypoints=https"
- "traefik.http.routers.myapp.rule=Host(`test.com`) && PathPrefix(`/myapp`)"
- "traefik.http.routers.myapp.service=myapp"
- "traefik.http.routers.myapp.tls=true"
- "traefik.http.services.myapp.loadbalancer.server.port=80" #this is needed to point to the correct port on the service container
- "treafik.docker.network=traefik"