title: Docker traefik PathPrefix with StripPrefix Middleware always throws HTTP_502
body: <p>I have a swarm service container, exposing port 5500. In the container, there is a web UI on <a href="https://localhost:5500/app" rel="noreferrer">https://localhost:5500/app</a>.
  My service is called service1.</p>
  
  <p>I am using a traefik 2 proxy and I want the web UI of my service1 to be available on <a href="https://proxy.domain.com/service1/app" rel="noreferrer">https://proxy.domain.com/service1/app</a>.</p>
  
  <p>My traefik labels for service1 are configured like this:</p>
  
  <pre><code>labels:
    - "traefik.http.routers.service1.rule=Host(`proxy.domain.com`) &amp;&amp; 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"
  </code></pre>
  
  <p>As I understood traefik, with this configuration I can call <a href="https://proxy.domain.com/service1/app" rel="noreferrer">https://proxy.domain.com/service1/app</a> 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.</p>
  
  <p>But when I call <a href="https://proxy.domain.com/service1/app" rel="noreferrer">https://proxy.domain.com/service1/app</a> in my browser, I get HTTP_502 Bad gateway.</p>
  
  <p>When I do <code>curl -v https://proxy.domain.com/service1/app</code>, I also get HTTP_502.</p>
  
  <p>When I do <code>curl -v https://proxy.domain.com:5500/app</code>, 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).</p>
  
  <p>What am I doing wrong? Have I misconfigured my traefik labels?</p>