Path-Based routing + Docker Compose not working

The rule can be simplified to:

      - "traefik.frontend.rule=PathPrefixStrip:/traefik"

As described in https://docs.traefik.io/v1.7/basics/#matchers:

  • You can see any Path*Strip, which first matches the request, as its corresponding Path* counterpart, but second, rewrite the request to strip the prefix.
  • Path only matches an exact path, not its subsequent-paths. So you have to use PathPrefix instead (or PathPrefixStrip in your case, to match all the sub-requests.

Last issue: the dashboard does not answer to HTTP's HEAD request (which is the kind of request emitted by curl with the option -I as per https://curl.haxx.se/docs/httpscripting.html#HEAD ). Try a full request as curl -v localhost/traefik.

Here is my complete and fully working example:

version: '3.7'

services:
  reverse-proxy:
    image: traefik:1.7.12
    command:
      - "--docker"
      - "--api"
    ports:
      - "80:80"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    labels:
      - "traefik.frontend.rule=PathPrefixStrip:/traefik"
      - "traefik.port=8080"