title: How to run Matomo behind Traefik with sub path?
body: <p>I'm setting up a docker-compose environment with Traefik (v1.7.16) as reverse proxy and want to include Matomo. I use the Bitnami images for Matomo and the backup database (MariaDB); both <code>latest</code>. The setup is similar to <a href="https://github.com/bitnami/bitnami-docker-matomo/blob/master/docker-compose.yml" rel="nofollow noreferrer">Bitnami's example compose file</a>.</p>
  
  <p>I followed the instructions provided and everything works fine, except the routing with Traefik. E.g. I can run Matomo at <code>localhost:&lt;exposedPort&gt;</code> but not at <code>localhost/matomo</code>, so sub paths are not working.</p>
  
  <p>What I did so far: As explained in the <a href="https://matomo.org/faq/how-to-install/faq_98/" rel="nofollow noreferrer">Matomo FAQ</a> I set the env variable <code>MATOMO_ENABLE_PROXY_URI_HEADER=yes</code> to set <code>proxy_uri_header = 1</code> in the <code>config.ini.php</code> (this works). Then I set the traefik labels for the Matomo service:</p>
  
  <pre><code>labels:
    - 'traefik.backend=matomo'
    - 'traefik.docker.network=proxy_traefik'
    - 'traefik.enable=true'
    - 'traefik.frontend.headers.STSPreload=true'
    - 'traefik.frontend.headers.STSSeconds=31536000'
    - 'traefik.frontend.rule=Host:localhost; PathPrefixStrip:/matomo;'
    - 'traefik.frontend.headers.customRequestHeaders=X-Forwarded-Uri:localhost/matomo'
    - 'traefik.frontend.headers.hostsProxyHeaders=X-Forwarded-Uri'
    - 'traefik.port=80'
  </code></pre>
  
  <p>As a result i can load the page <code>localhost/matomo</code> but all internal URLs (like image and script URLs) refer to <code>localhost</code> only and doesn't include the path <code>/matomo</code>.</p>
  
  <p>Is there something I missed setting up Traefik and Matomo?</p>