Added the possibility to handle multiple frontends in Docker backend provider #554
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
We encountered a little issue when working with traefik, in a special use case we had, when using the Docker backend provider. The scenario is better explained by the means of an example, so below is a
docker-compose.ymlwe created to test this scenario:As you can see we have two
whoamicontainers which are part of the same backend. We wanted these containers to have a frontend rule that matches the hostwhoami.docker.localhost, but we also wanted these containers to have another frontend rule that matches the hostproxy.docker.localhostand all paths prefixed by/whoami(which must be stripped from the URL). So, using the file backend, this were resulting in atraefik.tomlfile like the one below:This worked fine, so we could have the following answers:
(Notice the path stripped in the second request).
So we deeped into the documentation and traefik's code in order to see if we could translate this configuration inside the Docker backend provider, but all of our tries didn't work because in any case we got two separated frontends created. We tried configurations like the one below:
None worked. Finally, we decided to modify traefik's docker provider source code and
docker.tmplfile to meet our needs. This PR allows us to create separated frontends which matches the same backend, with different rules. This can be tested using the followingdocker-compose.ymlfile:We used the
&&separator in order to specify more than one frontend, because it worked for us, but we could change it to something else. Everything now worked fine: