1 min read

Install Metabase in a Sub-folder Behind Traefik

This is how you can install Metabase in a sub-folder behind Traefik.

docker-compose.yml
services:
  metabase:
    image: metabase/metabase
    networks:
      - traefik
    environment:
      # Important! path must be end with a trailing slash
      - MB_SITE_URL=https://domain.com/metabase/
    labels:
      - traefik.enable=true
 
      - traefik.http.services.metabase.loadbalancer.server.port=3000
      - traefik.http.middlewares.metabase-strip.stripprefix.prefixes=/metabase
 
      # HTTP entrypoint
      - traefik.http.routers.metabase-http.entrypoints=http
      - traefik.http.routers.metabase-http.rule=Host(`domain.com`) && PathPrefix(`/metabase`)
      - traefik.http.routers.metabase-http.middlewares=https-redirect,metabase-strip
 
      # HTTPS entrypoint
      - traefik.http.routers.metabase-https.entrypoints=https
      - traefik.http.routers.metabase-https.rule=Host(`domain.com`) && PathPrefix(`/metabase`)
      - traefik.http.routers.metabase-https.tls=true
      - traefik.http.routers.metabase-https.middlewares=metabase-strip
 
networks:
  traefik:
    external: true

For clarity, I ommited the Traefik part and assumed that Traefik is set up in another compose file. With this setup, Metabase can be accessed via https://domain.com/metabase.