Unable to run container behind Traefik Proxy with Path rule
Opened this issue · 1 comments
I'm desperately trying to run CyberChef behind traefik, all the containers I tried so far were not working. Even building from source...
Anyway. This is my docker-compose.yml:
version: "3.3"
services:
traefik:
image: "traefik:latest"
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
whoami:
image: "traefik/whoami"
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.rule=Host(`localhost`) && Path(`/whoami/`)"
- "traefik.http.routers.whoami.entrypoints=web"
cyberchef:
image: "mwalbeck/cyberchef:latest"
labels:
- "traefik.enable=true"
- "traefik.http.routers.cyberchef.rule=Host(`localhost`) && Path(`/cyberchef/`)"
- "traefik.http.routers.cyberchef.entrypoints=web"
nginx:
image: "nginx"
labels:
- "traefik.enable=true"
- "traefik.http.routers.nginx.rule=Host(`localhost`)"
- "traefik.http.routers.nginx.entrypoints=web"
volumes:
- ./static:/usr/share/nginx/html
When removing Path(`/cyberchef`)
from the docker and removing the nginx container with the same rule, the application will run at localhost
. So Cyberchef is working. But as soon, as I use the Path() rule, I get a 404 and the following traceback from the docker compose command:
mytoolbox-cyberchef-1 | 2022/10/28 12:54:30 [error] 29#29: *1 "/usr/share/nginx/html/cyberchef/index.html" is not found (2: No such file or directory), client: 172.18.0.5, server: localhost, request: "GET /cyberchef/ HTTP/1.1", host: "localhost"
mytoolbox-cyberchef-1 | 172.18.0.5 - - [28/Oct/2022:12:54:30 +0000] "GET /cyberchef/ HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36" "172.18.0.1"
Any ideas what the issue is?
Hi, I don't know if it's still relevant for you but after a quick look I think I see what the issue is. Because you're accessing CyberChef at localhost/cyberchef/
CyberChef tries to find the index.html at /usr/share/nginx/html/cyberchef/index.html
instead of /usr/share/nginx/html/index.html
where it is actually located.
This is normal webserver behaviour. Usually a root directory is defined, and in this case it is /usr/share/nginx/html
so when you access a subpath like localhost/cyberchef
it treats it like a directory path where localhost/
is the root.
I know with Nginx you can do some rewrite rules to you can make localhost/cyberchef/ point to the "root" of another service, but I don't have any experience with traefik, so I can't help you there.