Literally what is described in the title, I configured CF Tunnel + Traefik, so that I create a single hostname in CF like app.mydomain.com
, and in Traefik I created a router with a Path rule for two containers: whoami and portainer. Whoami works 100%, but Portainer gives me 404 page not found by Traefik, look at my configs:
Docker compose:
networks:
selfhost:
external: true
services:
cloudflare_tunnel:
container_name: cloudflare_tunnel
image: cloudflare/cloudflared:1681-ac57ed970926
restart: unless-stopped
command: tunnel --no-autoupdate run
environment:
TUNNEL_TOKEN: mytoken
networks:
- selfhost
portainer:
image: portainer/portainer-ce:2.21.5
container_name: portainer
networks:
- selfhost
volumes:
- ./portainer:/data
- /var/run/docker.sock:/var/run/docker.sock
restart: unless-stopped
whoami:
image: traefik/whoami:v1.10
container_name: whoami
networks:
- selfhost
restart: unless-stopped
traefik:
image: traefik:v3.2
container_name: traefik
networks:
- selfhost
volumes:
- ./traefik.yml:/etc/traefik/traefik.yml:ro
- ./config:/config:ro
restart: unless-stopped
Static Traefik.yml:
entryPoints:
web:
address: :80
api:
insecure: true
providers:
file:
directory: /config
watch: true
log:
level: DEBUG
My config/dynamic.yml:
http:
routers:
whoami:
rule: Path(`/whoami`)
service: whoami
entryPoints:
- web
portainer:
rule: Path(`/portainer`)
service: portainer
entryPoints:
- web
services:
whoami:
loadBalancer:
servers:
- url: http://whoami:80
portainer:
loadBalancer:
servers:
- url: http://portainer:9000
On Cloudflare tunnel hostnames, this is what I configured:
whoami.mydomain.com
-> http://whoami:80
portainer.mydomain.com
-> http://portainer:9000
traefik.mydomain.com
-> http://traefik:8080
app.mydomain.com
-> http://traefik:80
I don't need to bind the container ports, since CF Tunnel have access to the containers through the docker network DNS, so I can just use the containers' internal ports directly.
Current behavior:
All the three first hostnames work: whoami.
, portainer.
and traefik.
, but when it comes to the last one app.
, I type in the browser app.mydomain.dev/whoami
and it works, but if I type instead app.mydomain.com/portainer
, Traefik gives me 404 page not found
.
What am I missing here? You can see that portainer is working with its own subdomain, but not for path!
PS.: I just added a new router and service for Traefik like below, and I got the SAME error as Portainer... I even tested reordering the routers in the dynamic.yml
file, but only WHOAMI works at all.
http:
routers:
# ...
dashboard:
rule: Path(`/traefik`)
service: dashboard
entryPoints:
- web
services:
# ...
dashboard:
loadBalancer:
servers:
- url: http://traefik:8080