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

Hello
I have a docker container up and running and want to access it via https://mydomain.com/container.
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:

https://mydomain.com/main.3456423423.js

not the expected

https://mydomain.com/zigbee2mqtt/main.3456423423.js

The labels attached to the container:

      - "traefik.enable=true"
      - "traefik.http.routers.zigbee2mqtt.rule=Host(`mydomain.com`) && 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.services.zigbee2mqtt.loadbalancer.server.port=8080"
      - "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 zigbee2mqtt.mydomain.com 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 https://mydomain.com/main.3456423423.js. 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(`mydomain.com`) && PathPrefix(`/zigbee2mqtt`)"

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