title: Traefik 'PathPrefix' is not working as expected for underlying requests
body: <p>Trying to achieve simple Nginx routing of request in Traefik.
  Unfortunately, Traefik's <code>PathPrefix</code> is not working out of the box</p>
  <pre><code>location /app1/ {
      proxy_bind $server_addr;
      proxy_pass http://my-subdomain.localhost/app1/;
  }
  
  location /app2/ {
      proxy_bind $server_addr;
      proxy_pass http://my-subdomain.localhost/app2/;
  }
  
  location /app3/ {
      proxy_bind $server_addr;
      proxy_pass http://my-subdomain.localhost/app3/;
  }
  </code></pre>
  <p>Traefik configuration code using docker-compose to spin all the services.</p>
  <p>File : <code>dockercompose.yml</code></p>
  <pre><code>version: '3.3'
  
  services:
  
    traefik-reverse-proxy:
      container_name: traefik-reverse-proxy
      image: traefik:v2.2
      command:
        - &quot;--log.level=DEBUG&quot;
        - &quot;--api.insecure=true&quot;
        - &quot;--providers.docker=true&quot;
        - &quot;--providers.docker.exposedbydefault=false&quot;
        - &quot;--entrypoints.web.address=:80&quot;
      ports:
        - &quot;80:80&quot;
      volumes:
        - &quot;/var/run/docker.sock:/var/run/docker.sock:ro&quot;
      labels:
        - &quot;traefik.enable=true&quot;
        - &quot;traefik.http.routers.reverse-proxy.rule=Host(`my-subdomain.localhost`) &amp;&amp; PathPrefix(`/traefik`)&quot;
        - &quot;traefik.http.routers.reverse-proxy.service=api@internal&quot;
  
    app1:
      container_name: app1
      image: registry.gitlab.com/my-hobby-project/app1:latest
      labels:
        - &quot;traefik.enable=true&quot;
        - &quot;traefik.http.routers.app1.rule=(Host(`my-subdomain.localhost`) &amp;&amp; PathPrefix(`/app1`))&quot;
      
    app2:
      container_name: app2
      image: registry.gitlab.com/my-hobby-project/app2:latest
      labels:
        - &quot;traefik.enable=true&quot;
        - &quot;traefik.http.routers.app2.rule=(Host(`my-subdomain.localhost`) &amp;&amp; PathPrefix(`/app2/`))&quot;
  
    app3:
      container_name: app3
      image: registry.gitlab.com/my-hobby-project/app3:latest
      labels:
        - &quot;traefik.enable=true&quot;
        - &quot;traefik.http.routers.app3.rule=(Host(`my-subdomain.localhost`) &amp;&amp; PathPrefix(`/app3`))&quot;
  
  </code></pre>
  <p>Hint:</p>
  <p>A.
  App3 is my angular app, in this case, I'm actually able to hit index.html page but underlying resources are getting 404.</p>
  <p>First request: <code>http://staging.localhost/app3</code> -&gt; finds index.html.</p>
  <p>Following request: such as <code>http://staging.localhost/assests/util.js</code> -&gt; 404 (I expected traefik should make this request as <a href="http://staging.localhost/app3/assests/util.js" rel="nofollow noreferrer">http://staging.localhost/app3/assests/util.js</a> )</p>
  <p>Also I tried using <a href="https://docs.traefik.io/middlewares/addprefix/" rel="nofollow noreferrer">AddPrefix</a> but didn't work.</p>
  <p>AddPrefix code:</p>
  <pre><code> - &quot;traefik.http.routers.app3.rule=Host(`staging.localhost`) &amp;&amp; (PathPrefix(`/app3`))&quot;
   - &quot;traefik.http.middlewares.add-app3.addprefix.prefix=/app3&quot;
   - &quot;traefik.http.routers.app3.middlewares=add-app3&quot;
  </code></pre>
  <p>B. Also tried with slash at the end of pathPrefix (checkout app2 example code above), unfortunately, it doesn't work too.</p>
  <p>C. Using Traefik version 2.2 (See docker-compose.yml file)</p>
  <blockquote>
  <p>Question:</p>
  <ol>
  <li>How can I access the traefik dashboard by using subdomain and pathPrefix i.e. <code>http://my-subdomain.localhost/traefik</code></li>
  <li>How can I access the underlying resources of Angular : <a href="http://my-subdomain.localhost/app3%60" rel="nofollow noreferrer">http://my-subdomain.localhost/app3`</a></li>
  </ol>
  </blockquote>