I'm trying to use Traefik to route to a number of services all running using docker-compose. What I'd like to do is access each service with a prefix, eg: 10.20.30.40/u10/xyz and 10.20.30.40/a10/abc instead of 10.20.30.40:8000/xyz and 10.20.30.40:8001/abc.
I have a `docker-compose.yml file where I'm starting my services a10,u10,x10, mongo,mosquitto and all are exposed on their own ports - this works. I'm now stuck with the correct parameters for Traefik. You can see some of the attempts and commenting out of parameters.
The services a10,u10 etc should only be accessible using a prefix and all over port 80. Load balancing should be possible, eg: docker-compose -f dc.yml --scale u10=3 --scale a10=5
When I run this if I try on my local machine: http://127.0.0.1/u10/somepage.html I get a gateway timeout error, or, if I don't try using --scale then I'll get a 404.
Internally these services communicate with each other over the specified ports (REST) without the prefix and this works internally.
version: "3"
services:
reverse-proxy:
image: traefik:v2.9
command:
- "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedByDefault=true"
- "--entrypoints.web.address=:80"
- "--accesslog=true"
ports:
- "80:80"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
u10:
image: "u10"
# container_name: u10
# ports:
# - 8540:8540 # !!!
depends_on:
- messagebus
restart: always
networks:
- attestationnetwork
volumes:
- ./a10.conf:/etc/a10.conf # !!!
labels:
- "traefik.enable=true"
# - "traefik.port=8540"
- "traefik.docker.network=my-internal-network"
- "traefik.http.routers.u10.rule=PathPrefix(`/u10`)"
- "traefik.http.routers.u10.entrypoints=web"
- "traefik.http.routers.u10.middlewares=u10"
- "traefik.http.middlewares.u10.stripprefix.prefixes=/u10"
- "traefik.http.middlewares.u10.stripprefix.forceSlash=false"
- "traefik.http.routers.u10.service=u10"
- "traefik.http.services.u10.loadbalancer.server.port=8540"
networks:
my-internal-network:
driver: bridge