Traefik 2 - Reverse Proxy to a Path

Hey there,

I'm trying to forward my phpMyAdmin docker container with Traefik from an internal 172.20.0.X address to a directory. I'm using the latest version of Traefik along with the latest phpMyAdmin container.

It is my understanding that phpMyAdmin container serves the web frontend directly on port 80 at / .

I've got a basic SSL configuration of Traefik and am trying to use Docker labels to make / implement this. I've found some other tickets and Docs around explaining how to achieve this but most seem to be outdated for Traefik v1 and trying to translate this to Traefik v2 hasn't worked.

Here are my current Labels:

  • 80
  • traefik.http.routers.phpdb.tls.certresolver letsencrypt
  • traefik.http.routers.phpdb.tls true
  • traefik.http.routers.phpdb.rule (Host( && Path(/path)) || (Host( && Path(/path))
  • traefik.http.routers.phpdb.middlewares admin-addprefix
  • traefik.http.routers.phpdb.entrypoints https
  • traefik.http.middlewares.phpdb.headers.customrequestheaders.X-Forwarded-Proto https
  • traefik.http.middlewares.admin-addprefix.addprefix.prefix /path

When I try accessing, I'm able to see the Apache2 (from the phpMyAdmin container) 4040 Not Found page but can't access the application itself. (it's not the Traefik 404 page).

If I remove all mentions of the /path from the Router or the prefix middleware, I'm able to access and use phpMyAdmin on the address. However my goal is to have it only show / respond from address.

I'm still very new so I'm sure I'm not doing something correctly somewhere and appreciate any and all help towards understanding why this isn't working.

Thank you!

  • L

To note: I've followed, tried doing this:

As well as using this to go from Traefik 1 to 2 with no results:

(adding this as I couldn't include it in the previous message)

You should try PathPrefix in your rule instead of Path like :

rule: "Host(``) && PathPrefix(`/path`)"

Sorry I'm not using rule in docker like you, I'm using rule in conf file. You have to adapt to your install.

1 Like

Hey there,

Thanks for your help, I've updated my Router rule to as follows from your suggestions:

However, I'm still getting this error when I try visiting the desired URL:


It still seems like I'm accessing the phpMyAdmin Image apache setup but not on the right / expected path and thus, apache is returning a 404.

May i sugger you to add PMA_ABSOLUTE_URI in your docker and add the fully-qualified path as the phpMyAdmin documentation relate here ?

I've already done this, the PMA_ABSOLUTE_URI env variable doesn't modify or change the URL under which PMA is hosted on or under, it only manages the security when logging into the application to make sure you're using the right domain.

tl;dr: I've already done this, it doesn't change or do anything to Apache in the Docker container.

Here I think this is the same problem as you encountered.

It seems that traefik pass /path to the docker as the url is called and you have to rewrite it with AddPrefix:/ rule.

Hope it help.


As explained in the above most post, I've tried passing the addprefix middleware / have been using this throughout my testing:

  • traefik.http.routers.phpdb.middlewares admin-addprefix
  • traefik.http.middlewares.admin-addprefix.addprefix.prefix /path

Along with the router rule with either:

    • traefik.http.routers.phpdb.rule = (Host( && Path(/path)) || (Host(h && Path(/path))

Or as you suggested earlier, the PathPrefix instead of the above mentioned Path(/path).

    • traefik.http.routers.phpdb.rule = (Host( && PathPrefix(/path)) || (Host(h && PathPrefix(/path))

I've also experimented with the RemovePath middleware for the /path as well without any results.

The Github ticket you linked is, at least to my understanding of Traefik relavent for Traefik v1 , not V2 as I can not find a mention or use for the PathPrefixStrip that the above Github ticket users / mentions in Traefik v2.

There is a guide on the Traefik v2 Docs that mentions how to convert from PathPrefixStrip for v2 (here: but that hasn't worked either.

I appreciate your help, I just haven't been able to assemble all these puzzle pieces into something that works yet. :frowning:

Update, I went back in and did some tweaking. Your mention of the prefix and re-reading the docs made me realize that I had to StripPrefix along with using the PathPrefix suggestion you had earlier.

After setting these rules up and restarting the Container, I'm now able to access the container interface (phpMyAdmin web interface) by browsing directly to the address.

However, going to the address on its own just loads up a blank page with the right Page Title. I'm assuming I'm now missing something that tells Traefik to forward directly to index.php rather than just the root page which does / displays nothing.

Here are all my current container tags: (image to make to make it easier to visualize)

Again, I appreciate all the help!

Edit: (the underline /db in the above screenshot is actually /path, just forgot to edit it as such)

[HS] This is the reason i declare traefik rules separated from docker declaration, i can't proprely read the conf you've done without an headache [/HS]

About Strip-prefix, I encountered and error that i never fixed with my rutorrent docker when i'm accessing http://sub.domain.tld/rutorrent, i've a blank page. I'm forced to use http://sub.domain.tld/rutorrent/ with a slash to the end.

I can't show you cause it's BasicAuth protected but try to add / to the URL.

1 Like

Hey there,

That is exactly what I've been getting as well:

  • :x:https://sub.domain.tld/path
  • :white_check_mark:https://sub.domain.tld/path/
  • :white_check_mark:https://sub.domain.tld/path/index.php

I assume there has to be some / or * somewhere that I'm missing to make the application directly accessible on the /path endpoint without having to add a / (so /path/) after to get it to work. It's a small inconvenience but something I'd like to figure out nether less eventually.

At least for now, I can access the container interface directly without too many issues on a /path/, I'd just eventually like to figure out how to get to it using just /path.

Thanks again!

I apologize for the Docker labels rather than the config, I'm in the reverse position where I struggle to understand the config explantations and am much more confident with understanding and setting up the labels for the containers themselves as I understand what each line does directly. :rofl:

1 Like