title: Routing paths with Traefik
body: <p>Currently I'm trying set up a loadbalancer/reverse proxy with Traefik for some docker containers. I'm having trouble with configuring Treafik to make my apps available using a some prefix paths. I'm able to get a basic Traefik configuration running using Docker and Docker compose, based on <a href="https://github.com/containous/traefik/blob/master/examples/compose-traefik.yml" rel="noreferrer">this example</a>. The problem is that I'm able to get the 'whoamI' container to be reachable at a path, but not my app and other containers.</p>
  
  <p>For example, I've created a docker-compose file (see below) to start the whoamI container, and five Portainer containers (so people can recreate the scenario). I would expect woamI to be available at <code>/wai</code> and Portainer at <code>/portainer1</code>.</p>
  
  <p>Instead, I can reach the whoamI webserver (via <code>/wai</code>) and not Portainer (via <code>/portainer1</code>). However, I am able to reach Portainer at <code>/portainer2</code>. The only difference in Traefik configuration between these two is the use of 'PathStrip' instead of 'Path'. The annoying thing, however, is that I can only obtain a white page when navigating to <code>/portainer2</code>; only the page title and some html is loaded. I have also started a Portainer container which is exposed to the host machine, to verify the expected behavior (a normal Portainer page). See also the attached image below.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Interestingly, I'm also able to reach Portainer at <code>/portainer4/</code> (but not <code>/portainer4</code>) resulting in the same white page. The difference between navigating to <code>/portainer2/</code> and <code>/portainer4/</code> is that I notice some additional logging in Traefik (see below). When navigating to Portainer via <code>/portainer4/</code>, three extra lines show up in the log indicating a 400 status. After some investigation, I found out that this comes from my browser's attempt to load additional files (i.e. a javascript file, a favicon and a stylesheet). So, when accessing Portainer at <code>/portainer4/</code> my browser knows it needs to fetch those extra files and tries to do so (which does not happen when navigating to <code>/portainer2</code>). When trying to access the files myself by, for example, navigating to <code>/portainer4/ico/favicon.ico</code>, I get a <code>400 Bad Request</code>. Lastly, when navigating to <code>/portainer2/ico/favicon.ico</code> is see a <code>404 page not found</code>.</p>
  
  <p>Based on these results I'm wondering:</p>
  
  <ul>
  <li>Why I cannot reach Portainer at /portainer1 but instead on
  /portainer2?</li>
  <li>Why I do not see the full Portainer page when navigating to
  /portainer2?</li>
  <li>Why there is a difference in behavior between accessing a file (e.g. the favicon) between <code>/portainer2/</code> and <code>/portainer4/</code></li>
  <li>What the 400 Bad Request actually means and if/how this problem this problem can be fixed</li>
  </ul>
  
  <p>I would really appreciate some pointers in the right direction</p>
  
  <p>Some screenshots:
  <a href="https://i.stack.imgur.com/kK6OG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kK6OG.png" alt="Different Treafik paths"></a></p>
  
  <p>docker-compose.yml:</p>
  
  <pre><code>version: '2'
  
  services:   
    traefik:
      container_name: traefik
      image: traefik
      command: --web --docker --docker.domain=docker.localhost --logLevel=DEBUG
      ports:
        - "80:80"
        - "8080:8080"
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock
        - /dev/null:/traefik.toml
      labels:
          - "traefik.enable=false"      
    whoami:
      image: emilevauge/whoami
      labels:
        - "traefik.backend=whoami"
        - "traefik.frontend.rule=Path: /wai/"   
    portainer1:
      image: portainer/portainer
      labels:
        - "traefik.backend=portainer1"
        - "traefik.frontend.rule=Path: /portainer1/"   
    portainer2:
      image: portainer/portainer
      labels:
        - "traefik.backend=portainer2"
        - "traefik.frontend.rule=PathStrip: /portainer2/"      
    portainer:
      image: portainer/portainer
      ports:
        - "9000:9000"
      labels:
          - "traefik.enable=false"
  </code></pre>
  
  <p>Additional Traefik logging generated after visiting <code>/wai</code>, <code>/portainer1/</code>, <code>&lt;myIP&gt;/portainer2/</code>, <code>/portainer3/</code> and <code>/portainer4/</code>, respectively:</p>
  
  <pre><code>time="2017-01-13T14:33:16Z" level=debug msg="Round trip: http://172.19.0.2:80, code: 200, duration: 1.000627ms"
  time="2017-01-13T14:33:22Z" level=debug msg="Round trip: http://172.19.0.7:9000, code: 404, duration: 1.006089ms"
  time="2017-01-13T14:33:24Z" level=debug msg="Round trip: http://172.19.0.3:9000, code: 200, duration: 1.160158ms"
  time="2017-01-13T14:33:26Z" level=debug msg="Round trip: http://172.20.0.5:9000, code: 404, duration: 1.291309ms"
  time="2017-01-13T14:33:29Z" level=debug msg="Round trip: http://172.20.0.4:9000, code: 200, duration: 2.788462ms"
  time="2017-01-13T14:33:29Z" level=debug msg="Round trip: http://172.20.0.4:9000, code: 400, duration: 777.073µs"
  time="2017-01-13T14:33:30Z" level=debug msg="Round trip: http://172.20.0.4:9000, code: 400, duration: 1.780621ms"
  time="2017-01-13T14:33:30Z" level=debug msg="Round trip: http://172.20.0.4:9000, code: 400, duration: 1.780341ms"
  </code></pre>