I had exactly the same issue few weeks ago! Getting Apache's "It works!" page instead of the whoami response was driving me crazy.
@HansKilian is right that it's weird - your docker ps
shows Traefik binding to port 80 correctly, so something else is intercepting the requests.
First, check what's actually using port 80:
sudo lsof -i :80
If you see Apache there, that's your problem - it's intercepting before Docker gets the request.
@YuvarajM's suggestion is solid - try moving Traefik to another port:
ports:
- "8081:80" # Change this line
- "8080:8080"
Then test: curl -H "Host: whoami.docker.localhost" http://127.0.0.1:8081
Or go with @DavidMaze's path-based routing approach (honestly, this avoids all the DNS headaches):
labels:
- "traefik.http.routers.whoami.rule=PathPrefix(`/whoami`)"
Access via: http://localhost:8081/whoami
@HansKilian mentioned checking your Docker context - this caught me once too:
docker context ls
Make sure the *
is on default
, not desktop-linux
. Sometimes WSL does weird things with contexts.
@Z4-tier's debugging tip is gold - connect directly to the container:
docker exec -it traefik-docker-rp-reverse-proxy-1 sh
# Inside container:
wget -qO- --header="Host: whoami.docker.localhost" http://localhost
Also check Traefik's dashboard at http://localhost:8080
- you should see your whoami service listed there. If it's not showing up, there's definitely a config issue.
Since you got "Move Permanently" when testing @YuvarajM's suggestion, Traefik might be trying to redirect HTTP to HTTPS. Try adding -L
to follow redirects:
curl -L -H "Host: whoami.docker.localhost" http://127.0.0.1:8081
The port change solution usually fixes both the Apache conflict and WSL networking issues. Let me know which approach works!