I have a docker containe that has many services running on many ports. For example jupyter will run on port 6006. But some networks block ports other than 80 (http). I looked into traefik and thought it would help me resolve those issues.
So instead of accessing host:6006 I want to access it using host/proxy/6006
Below is part of my code, what I have now I run the traefik image and docker image through a docker-compose file that seems to work and I'm able to access it by service1.docker.localhost
But I'd prefer something like localhost/docker/6006
labels:
- "traefik.enable=true"
- "traefik.http.routers.router1.rule=host(`service1.docker.localhost`)"
- "traefik.http.routers.router1.service=service1"
- "traefik.http.routers.router1.entrypoints=web"
- "traefik.http.services.service1.loadbalancer.server.port=6006"
I looked into middlewares but having found a solution that worked for me and I feel like I can't change the default host name without errors.
Hi williamjfermo,
Would you mind share additonal information about your environmet? Did you deploy traefik in a docker swarm cluster? If so, provide logs about your issue, please.
All the best
Deploying locally on a mac.
I'm using a docker-compose file to run the traefik image and the docker image. Here is my full code for the docker-compose.yml
version: '3.3'
services:
traefik:
image: traefik:v2.2
command:
- --providers.docker=true
- --entrypoints.web.address=:80
- --providers.docker.exposedbydefault=true
- --api.insecure=true
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
labels:
- "traefik.enable=true"
my-app:
image: "docker_example/image"
labels:
- "traefik.enable=true"
- "traefik.http.routers.router1.rule=host(`service1.docker.localhost`)"
- "traefik.http.routers.router1.service=service1"
- "traefik.http.routers.router1.entrypoints=web"
- "traefik.http.services.service1.loadbalancer.server.port=6006"
volumes:
- "~/datasets:/data"
- "./home/ubuntu/dev"
tty: true
I'm able to access this fine when using http://service1.docker.localhost but want to be able to run the file like this instead http://localhost/docker/6006
Was looking into RedirectRegex but couldn't every time I tried to change the default host name service1.docker.localhost into something else nothing really works.
Any help or direction would be great.