Using Traefix version 1.2.3 from the docker container I've set up the following file.
traefik:
image: traefik
command: --web --docker --docker.domain=docker.localhost --logLevel=DEBUG
ports:
- "80:80"
- "8080:8080"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /dev/null:/traefik.toml
services:
image: opencoredata/ocdservices:0.2
labels:
- "traefik.backend=services"
- "traefik.frontend.rule=Host:opencore.dev"
- "traefik.frontend.rule=PathPrefix:/api"
# web:
# image: opencoredata/ocdweb:0.3
# labels:
# - "traefik.backend=web"
# - "traefik.frontend.rule=Host:opencore.dev"
If I remove the comments around the "web" section all traffic will go to that container ignoring the Path or PathPrefix or any other attempt to get URLs with the beginning /api/ to go to the services container.
Commenting out the "web" container like above and the traffic goes to the services container. Which is expected since there is no other container of course.
I simply can not find how to get Traefik to work with Path, PathPrefix, PathPrefixStrip or any other combination. Examples here and in the docs seem to indicate I should get the behavior I want, but I can not realize it.
I think that this part
- "traefik.frontend.rule=Host:opencore.dev"
- "traefik.frontend.rule=PathPrefix:/api"
is wrong because second line overwrite the first one, try this :
- "traefik.frontend.rule=Host:opencore.dev;PathPrefix:/api"
I think it will combine stuff the way you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With