Running multiple endpoints ,
for one of them I create 1 middleware for basicauth ,
following @ldez example here:
it can be reuse ,I tried to implement the same
but the auth works only for the webserver and not for the second one .
services:
webserver:
build: .
container_name: webserver
command: uvicorn main:app --host 0.0.0.0 --port "${WEBSERVER_PORT:-8111}" --reload
volumes:
- ./backend/webserver:/webserver
networks:
- dockers_default
ports:
- "${WEBSERVER_PORT:-8111}:8111"
depends_on:
- mongo_db
labels:
traefik.enable: true
traefik.http.routers.webserver.rule: Host(`webserver.${DOMAINNAME}`)
traefik.http.routers.webserver.entrypoints: websecure
traefik.http.services.webserver.loadbalancer.server.port: "${WEBSERVER_PORT:-8111}"
traefik.http.routers.webserver.middlewares: auth_webserver
traefik.http.middlewares.auth_webserver.basicauth.users: ${WEBSERVER_USER}:${WEBSERVER_PASS},${GUEST_USER}:${GUEST_PASS}
mongo_gui:
image: huggingface/mongoku
container_name: mongo_gui
ports:
- "${MONGOGUI_PORT:-3100}:3100"
networks:
- dockers_default
depends_on:
- mongo_db
labels:
traefik.enable: true
traefik.http.routers.mongo.rule: Host(`mongo.${DOMAINNAME}`)
traefik.http.routers.mongo.entrypoints: websecure
traefik.http.services.mongo.loadbalancer.server.port: "${MONGOGUI_PORT:-3100}"
traefik.http.routers.mongo_gui.middlewares: auth_webserver
traefik.http.middlewares.mongo_gui.basicauth.removeheader: true