I have been trying to configure traefik as a reverse proxy for Streamlit. "traefik.http.routers.streamlit.rule=Host(
streamlit.localhost)"
works, but streamlit.localhost
URL returns properly. But "traefik.http.routers.streamlit.rule=Path(
/streamlit)"
doesn't work. localhost/streamlit
just returns 404
.
This is my docker-compose file.
version: "3.3"
services:
traefik:
image: "traefik:v2.6"
container_name: "traefik"
restart: unless-stopped
command:
#- "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
networks:
- traefik
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
whoami:
image: "traefik/whoami"
container_name: "simple-service"
networks:
- traefik
labels:
- "traefik.enable=true"
# This works
# - "traefik.http.routers.whoami.rule=Host(`whoami.localhost`)"
# This works
- "traefik.http.routers.whoami.rule=PathPrefix(`/whoami`)"
- "traefik.http.routers.whoami.entrypoints=web"
streamlit:
image: "streamlit:develop"
container_name: "streamlit"
command: pipenv run streamlit run streamlit-app.py
restart: unless-stopped
ports:
- 8501
networks:
- traefik
labels:
- "traefik.enable=true"
# This doesn't work
# - "traefik.http.routers.streamlit.rule=PathPrefix(`/streamlit`)"
# This doesn't work
# - "traefik.http.routers.streamlit.rule=Path(`/streamlit`)"
# This works
# - "traefik.http.routers.streamlit.rule=Host(`streamlit.localhost`)"
# `streamlit.localhost` works but `localhost/streamlit` doesn't work
- "traefik.http.routers.streamlit.rule=Host(`streamlit.localhost`) || PathPrefix(`/streamlit`)"
- "traefik.http.routers.streamlit.entrypoints=web"
- "traefik.http.services.streamlit.loadbalancer.server.port=8501"
networks:
traefik:
driver: bridge
Streamlit supports Streamlit Configuration. I've also tried setting the configuration, but couldn't get localhost/streamlit
URL working.
[server]
# The base path for the URL where Streamlit should be served from.
# Default: ""
baseUrlPath = "/streamlit"