I have a swarm service container, exposing port 5500. In the container, there is a web UI on https://localhost:5500/app. My service is called service1.
I am using a traefik 2 proxy and I want the web UI of my service1 to be available on https://proxy.domain.com/service1/app.
My traefik labels for service1 are configured like this:
labels:
- "traefik.http.routers.service1.rule=Host(`proxy.domain.com`) && PathPrefix(`/service1/app`)"
- "traefik.http.middlewares.strip-s1.stripprefix.prefixes=/service1"
- "traefik.http.routers.service1.service=service1@docker"
- "traefik.http.services.service1.loadbalancer.server.port=5500"
- "traefik.http.routers.service1.middlewares=strip-s1@docker"
- "traefik.http.routers.service1.entrypoints=https"
- "traefik.http.routers.service1.tls=true"
As I understood traefik, with this configuration I can call https://proxy.domain.com/service1/app what matches the rule of the router. Traefik will then strip the /service1 from the pathPrefix, so /app will remain and be forwarded to the service container on port 5500, so I think the container will get called on port 5500/app.
But when I call https://proxy.domain.com/service1/app in my browser, I get HTTP_502 Bad gateway.
When I do curl -v https://proxy.domain.com/service1/app
, I also get HTTP_502.
When I do curl -v https://proxy.domain.com:5500/app
, it works and I connect to port 5500/app and get redirected to port 5500/app/login in the container (this redirect is done by the web application behind /app).
What am I doing wrong? Have I misconfigured my traefik labels?