Accessing a docker container via subpath fails to load html scripts/css

I have a docker container up and running and want to access it via
The inital redirect seems to work, but the frontent listening there tries to load content from /.

Browser debug:

everything which should be loaded from the index page is returning a 404
EDIT: when hovering over the File column in the debug window, I can see the fully qualified name, where the page is looking for the content. It is i.e:

not the expected

The labels attached to the container:

      - "traefik.enable=true"
      - "traefik.http.routers.zigbee2mqtt.rule=Host(``) && Path(`/zigbee2mqtt`)"
      - "traefik.http.routers.zigbee2mqtt.entrypoints=websecure"
      - "traefik.http.routers.zigbee2mqtt.tls=true"
      - "traefik.http.routers.zigbee2mqtt.middlewares=zigbee2mqtt-auth,zigbee2mqtt-stripprefix"
      - ""
      - "traefik.http.middlewares.zigbee2mqtt-auth.basicauth.users=openhab:$$apr1$$xxxxxxxxxxxxx"
      - "traefik.http.middlewares.zigbee2mqtt-stripprefix.stripprefix.prefixes=/zigbee2mqtt"
      - "traefik.http.middlewares.zigbee2mqtt-stripprefix.stripprefix.forceslash=false"

Any idea how to fix that?

Another Edit:
I can not configure the application to be aware its subpath. It does simply not have that option.

That is your solution when using a path prefix. The software will usually require a configuration change unless it is extraordinarily well done.

is there any other way to archieve this? reaching this container by subpath?

It may be easier to create/use a subdomain instead, as this would allow to leave the path untouched.
Otherwise it is possible if you put an Apache in between and use mod_rewrite to change the path - but this is a nightmare to debug...

1 Like

I forgot to explain the likely reason for your problem:
It is no problem with Traefik or stripping the prefix, but caused by the app itself, as it uses absolute URL paths to include resources - so instead of just including main.3456423423.js it includes /main.3456423423.js or You can verify this behavior by looking at the page source.

Independent of this problem you should use PathPrefix instead of Path - otherwise it would not match anything below /zigbee2mqtt/:

      - "traefik.http.routers.zigbee2mqtt.rule=Host(``) && PathPrefix(`/zigbee2mqtt`)"

Maybe another possible workaround would be using another entrypoint (=port) for the zigbee2mqtt.