Treafik Path Routing
I want to reach a docker-compose service under api.example.com/example. Therefore I have the following docker-compose.yml
example:
image: example
labels:
- "traefik.frontend.rule=Host:api.example.com;PathPrefixStrip:/example/"
- "traefik.enable=true"
- "traefik.protocol=http"
- "traefik.frontend.entryPoints=https"
I can reach the service under this path. But all the links in the page route to a wrong url like api.example.com/link
instead of api.example.com/example/link
Also the css is not loading correctly because of this path issue.
What would be the right path configuration to get this working?
Reading from the docs, X-Forwarded-Prefix should be the solution, but there is no doc about.
docker docker-compose reverse-proxy traefik
add a comment |
I want to reach a docker-compose service under api.example.com/example. Therefore I have the following docker-compose.yml
example:
image: example
labels:
- "traefik.frontend.rule=Host:api.example.com;PathPrefixStrip:/example/"
- "traefik.enable=true"
- "traefik.protocol=http"
- "traefik.frontend.entryPoints=https"
I can reach the service under this path. But all the links in the page route to a wrong url like api.example.com/link
instead of api.example.com/example/link
Also the css is not loading correctly because of this path issue.
What would be the right path configuration to get this working?
Reading from the docs, X-Forwarded-Prefix should be the solution, but there is no doc about.
docker docker-compose reverse-proxy traefik
add a comment |
I want to reach a docker-compose service under api.example.com/example. Therefore I have the following docker-compose.yml
example:
image: example
labels:
- "traefik.frontend.rule=Host:api.example.com;PathPrefixStrip:/example/"
- "traefik.enable=true"
- "traefik.protocol=http"
- "traefik.frontend.entryPoints=https"
I can reach the service under this path. But all the links in the page route to a wrong url like api.example.com/link
instead of api.example.com/example/link
Also the css is not loading correctly because of this path issue.
What would be the right path configuration to get this working?
Reading from the docs, X-Forwarded-Prefix should be the solution, but there is no doc about.
docker docker-compose reverse-proxy traefik
I want to reach a docker-compose service under api.example.com/example. Therefore I have the following docker-compose.yml
example:
image: example
labels:
- "traefik.frontend.rule=Host:api.example.com;PathPrefixStrip:/example/"
- "traefik.enable=true"
- "traefik.protocol=http"
- "traefik.frontend.entryPoints=https"
I can reach the service under this path. But all the links in the page route to a wrong url like api.example.com/link
instead of api.example.com/example/link
Also the css is not loading correctly because of this path issue.
What would be the right path configuration to get this working?
Reading from the docs, X-Forwarded-Prefix should be the solution, but there is no doc about.
docker docker-compose reverse-proxy traefik
docker docker-compose reverse-proxy traefik
edited Nov 13 '18 at 12:24
Florian
asked Nov 13 '18 at 12:05
FlorianFlorian
591724
591724
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
If I understand correctly, you only want to route requests matching api.example.com/example/*
to this example
service. Then you should use PathPrefix:/example/
.
What you have is expected: PathPrefixStrip
, as the name suggests, try to match the path, then, remove it before routing traffic to the service.
yes but my service behind is listening on/
not on/example/
so I have to strip theexample
, so this will not work, no?
– Florian
Nov 13 '18 at 13:09
As far as I know, servers don't listen to a path, they always "listen" to/
(they are on a host). Your apis, though, can be on any path you like, leaving/
to a 404 page.
– Siyu
Nov 13 '18 at 13:31
yeah this is right, but I therefore use traefik. I want to have several servers listening on/
but path routed by traefik. I thought PathPrefixStrip is exactly therefore. Instead, I would not understand the use of traefik with paths
– Florian
Nov 13 '18 at 13:35
The goal here is to have a finer grade scaling control, decoupling the system (concept of microservice) while appear to the outside world as one server.
– Siyu
Nov 13 '18 at 13:48
When you say you want to have several servers listening on /, do you mean that a server A and a server both respond to domain/test ?
– Siyu
Nov 13 '18 at 13:49
|
show 2 more comments
Did you try to add rules ?
- "traefik.frontend.rule=Host:api.example.com;PathPrefixStrip:/example/; AddPrefix: /example"
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280683%2ftreafik-path-routing%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
If I understand correctly, you only want to route requests matching api.example.com/example/*
to this example
service. Then you should use PathPrefix:/example/
.
What you have is expected: PathPrefixStrip
, as the name suggests, try to match the path, then, remove it before routing traffic to the service.
yes but my service behind is listening on/
not on/example/
so I have to strip theexample
, so this will not work, no?
– Florian
Nov 13 '18 at 13:09
As far as I know, servers don't listen to a path, they always "listen" to/
(they are on a host). Your apis, though, can be on any path you like, leaving/
to a 404 page.
– Siyu
Nov 13 '18 at 13:31
yeah this is right, but I therefore use traefik. I want to have several servers listening on/
but path routed by traefik. I thought PathPrefixStrip is exactly therefore. Instead, I would not understand the use of traefik with paths
– Florian
Nov 13 '18 at 13:35
The goal here is to have a finer grade scaling control, decoupling the system (concept of microservice) while appear to the outside world as one server.
– Siyu
Nov 13 '18 at 13:48
When you say you want to have several servers listening on /, do you mean that a server A and a server both respond to domain/test ?
– Siyu
Nov 13 '18 at 13:49
|
show 2 more comments
If I understand correctly, you only want to route requests matching api.example.com/example/*
to this example
service. Then you should use PathPrefix:/example/
.
What you have is expected: PathPrefixStrip
, as the name suggests, try to match the path, then, remove it before routing traffic to the service.
yes but my service behind is listening on/
not on/example/
so I have to strip theexample
, so this will not work, no?
– Florian
Nov 13 '18 at 13:09
As far as I know, servers don't listen to a path, they always "listen" to/
(they are on a host). Your apis, though, can be on any path you like, leaving/
to a 404 page.
– Siyu
Nov 13 '18 at 13:31
yeah this is right, but I therefore use traefik. I want to have several servers listening on/
but path routed by traefik. I thought PathPrefixStrip is exactly therefore. Instead, I would not understand the use of traefik with paths
– Florian
Nov 13 '18 at 13:35
The goal here is to have a finer grade scaling control, decoupling the system (concept of microservice) while appear to the outside world as one server.
– Siyu
Nov 13 '18 at 13:48
When you say you want to have several servers listening on /, do you mean that a server A and a server both respond to domain/test ?
– Siyu
Nov 13 '18 at 13:49
|
show 2 more comments
If I understand correctly, you only want to route requests matching api.example.com/example/*
to this example
service. Then you should use PathPrefix:/example/
.
What you have is expected: PathPrefixStrip
, as the name suggests, try to match the path, then, remove it before routing traffic to the service.
If I understand correctly, you only want to route requests matching api.example.com/example/*
to this example
service. Then you should use PathPrefix:/example/
.
What you have is expected: PathPrefixStrip
, as the name suggests, try to match the path, then, remove it before routing traffic to the service.
answered Nov 13 '18 at 12:41
SiyuSiyu
2,6431727
2,6431727
yes but my service behind is listening on/
not on/example/
so I have to strip theexample
, so this will not work, no?
– Florian
Nov 13 '18 at 13:09
As far as I know, servers don't listen to a path, they always "listen" to/
(they are on a host). Your apis, though, can be on any path you like, leaving/
to a 404 page.
– Siyu
Nov 13 '18 at 13:31
yeah this is right, but I therefore use traefik. I want to have several servers listening on/
but path routed by traefik. I thought PathPrefixStrip is exactly therefore. Instead, I would not understand the use of traefik with paths
– Florian
Nov 13 '18 at 13:35
The goal here is to have a finer grade scaling control, decoupling the system (concept of microservice) while appear to the outside world as one server.
– Siyu
Nov 13 '18 at 13:48
When you say you want to have several servers listening on /, do you mean that a server A and a server both respond to domain/test ?
– Siyu
Nov 13 '18 at 13:49
|
show 2 more comments
yes but my service behind is listening on/
not on/example/
so I have to strip theexample
, so this will not work, no?
– Florian
Nov 13 '18 at 13:09
As far as I know, servers don't listen to a path, they always "listen" to/
(they are on a host). Your apis, though, can be on any path you like, leaving/
to a 404 page.
– Siyu
Nov 13 '18 at 13:31
yeah this is right, but I therefore use traefik. I want to have several servers listening on/
but path routed by traefik. I thought PathPrefixStrip is exactly therefore. Instead, I would not understand the use of traefik with paths
– Florian
Nov 13 '18 at 13:35
The goal here is to have a finer grade scaling control, decoupling the system (concept of microservice) while appear to the outside world as one server.
– Siyu
Nov 13 '18 at 13:48
When you say you want to have several servers listening on /, do you mean that a server A and a server both respond to domain/test ?
– Siyu
Nov 13 '18 at 13:49
yes but my service behind is listening on
/
not on /example/
so I have to strip the example
, so this will not work, no?– Florian
Nov 13 '18 at 13:09
yes but my service behind is listening on
/
not on /example/
so I have to strip the example
, so this will not work, no?– Florian
Nov 13 '18 at 13:09
As far as I know, servers don't listen to a path, they always "listen" to
/
(they are on a host). Your apis, though, can be on any path you like, leaving /
to a 404 page.– Siyu
Nov 13 '18 at 13:31
As far as I know, servers don't listen to a path, they always "listen" to
/
(they are on a host). Your apis, though, can be on any path you like, leaving /
to a 404 page.– Siyu
Nov 13 '18 at 13:31
yeah this is right, but I therefore use traefik. I want to have several servers listening on
/
but path routed by traefik. I thought PathPrefixStrip is exactly therefore. Instead, I would not understand the use of traefik with paths– Florian
Nov 13 '18 at 13:35
yeah this is right, but I therefore use traefik. I want to have several servers listening on
/
but path routed by traefik. I thought PathPrefixStrip is exactly therefore. Instead, I would not understand the use of traefik with paths– Florian
Nov 13 '18 at 13:35
The goal here is to have a finer grade scaling control, decoupling the system (concept of microservice) while appear to the outside world as one server.
– Siyu
Nov 13 '18 at 13:48
The goal here is to have a finer grade scaling control, decoupling the system (concept of microservice) while appear to the outside world as one server.
– Siyu
Nov 13 '18 at 13:48
When you say you want to have several servers listening on /, do you mean that a server A and a server both respond to domain/test ?
– Siyu
Nov 13 '18 at 13:49
When you say you want to have several servers listening on /, do you mean that a server A and a server both respond to domain/test ?
– Siyu
Nov 13 '18 at 13:49
|
show 2 more comments
Did you try to add rules ?
- "traefik.frontend.rule=Host:api.example.com;PathPrefixStrip:/example/; AddPrefix: /example"
add a comment |
Did you try to add rules ?
- "traefik.frontend.rule=Host:api.example.com;PathPrefixStrip:/example/; AddPrefix: /example"
add a comment |
Did you try to add rules ?
- "traefik.frontend.rule=Host:api.example.com;PathPrefixStrip:/example/; AddPrefix: /example"
Did you try to add rules ?
- "traefik.frontend.rule=Host:api.example.com;PathPrefixStrip:/example/; AddPrefix: /example"
answered Nov 16 '18 at 22:03
DamDamDamDam
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280683%2ftreafik-path-routing%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown