I have two basic flask apps that I've created containers for. I'm trying to use traefik to route to one container when visiting "localhost" (soon to be replaced wit an actual domain) and to another container when visiting "localhost/app2". When I do a docker-compose up and visit the trafik dashboard, I can see the urls have been created and I can successfully visit them. I can visit "localhost" and it correctly routes to my first flask app but "localhost/app2" leaves me with a 404/Not found error, likely because it's still visiting that first app. How can I correctly route the second app? Here's my docker-compose file:
version: '3'
services:
app1:
build: .
command: /usr/bin/python3 fapp1.py
networks:
- test_network
- internal
ports:
- "8000:8000"
labels:
- "traefik.frontend.rule=Host:localhost"
app2:
build: .
command: /usr/bin/python3 fapp2.py
networks:
- test_network
- internal
ports:
- "8001:8001"
labels:
- "traefik.frontend.rule=Host:localhost/app2"
reverse-proxy:
image: traefik # The official Traefik docker image
command: --api --docker # Enables the web UI and tells Traefik to listen to docker
ports:
- "80:80" # The HTTP port
- "8080:8080" # The Web UI (enabled by --api)
volumes:
- /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker eventsdoc
networks:
- test_network
- internal
networks:
test_network:
external: true
internal:
external: false
And the urls that get created for each respective app:
app1: http://172.23.0.3:8000/ app2: http://172.23.0.4:8001/
Thanks!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.