Dashboard StripPrefix

Hi everyone,

I try to put the API and the dashboard one subfolder down under /traefik, which works in general, but the StripPrefix and the dashboard do not work together. All returned links are not prefixed with my prefix, as they should be according to the documentation of StripPrefix. My docker-compose.yml file is this:

version: '2'

services:
  traefik:
    image: traefik:2.0
    command: --api.insecure=true --providers.docker --log.level=DEBUG --entryPoints.http.address=:80 --entryPoints.https.address=:443
    restart: unless-stopped
    ports:
    - 80:80
    - 8080:8080
    - 443:443
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    labels:
    # printf "traefik:$( openssl passwd -apr1 traefik 2>&1 | sed -e 's/\$/\$\$/g')"
    - traefik.http.middlewares.auth.basicauth.users=traefik:$$apr1$$SgL.xvfB$$pAb2/ufjHlC8dyLK9ssdW1
    - traefik.http.routers.api.middlewares=chain
    - traefik.http.routers.api.rule=PathPrefix(`/traefik`)
    - traefik.http.routers.api.service=api@internal
    # TLS stuff including redirection
    - traefik.http.middlewares.https_redirect.redirectscheme.scheme=https
    - traefik.http.routers.api.tls=true
    - traefik.http.routers.api.entryPoints=https
    - traefik.http.routers.api_http.middlewares=https_redirect
    - traefik.http.routers.api_http.entryPoints=http
    - traefik.http.routers.api_http.rule=PathPrefix(`/traefik`)
    # Middleware Chain
    - traefik.http.middlewares.chain.chain.middlewares=auth,path-strip
    - traefik.http.middlewares.path-strip.stripprefix.prefixes=/traefik

I also activated the insecure API in order to "look at things", but everything looks ok to me.

Best,
Andreas

You can follow https://github.com/containous/traefik/issues/5374

The bug is closed, but I am unable to locate in the documentation how to set this up with a reverse proxy.

I've tried

        - traefik.http.routers.api.rule=Host(`i.trajano.net`) && ( PathPrefix(`/traefik/api`) || PathPrefix(`/traefik/dashboard`) || PathPrefix(`/traefik/debug`))
        - traefik.http.routers.api.entryPoints=https
        - traefik.http.routers.api.tls.certresolver=default
        - traefik.http.routers.api.tls.options=intranet@file
        - traefik.http.routers.api.service=api@internal
        - traefik.http.routers.api.middlewares=strip-prefix@file

I've also tried to test it against 2.1

1 Like

Related: How to add path prefix to api endpoints?

It does not seem it has actually been fixed: https://github.com/containous/traefik/issues/5853

There were some vaguely related fixes in the general area, but it seems that you still cannot host the dashboard on the arbitrary prefix, because the /api path is hardcoded.