Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X-Forwarded-Prefix header support #304

Closed
avarabyeu opened this issue Jun 6, 2017 · 8 comments
Closed

X-Forwarded-Prefix header support #304

avarabyeu opened this issue Jun 6, 2017 · 8 comments
Milestone

Comments

@avarabyeu
Copy link

While using fabio with urlprefix option, X-Forwarded-Prefix header is not passed to downstream requests.
In this case downstream services are not able to generate correct back-links since they don't know their real path.

@magiconair
Copy link
Contributor

How many of these headers are there? :)

What would it need to contain? The original request path?

@avarabyeu
Copy link
Author

avarabyeu commented Jun 6, 2017

In my personal case i'd like to have the same behaviour that i had with Zuul :)
For example,
urlprefix-/myprefix opts strip=/myprefix
Since /myprefix is being stripped, X-Forwarded-Prefix=/myprefix should be added to be able to build valid request URL from upstream proxy.
So yeah, it's original request path. But seems like only when you strip some part of it.

btw, as far as i know, the following list are usually added:

  • Forwarded
  • X-Forwarded-Host
  • X-Forwarded-Port
  • X-Forwarded-Proto
  • X-Forwarded-Prefix

Another important point is that you have to keep those headers from upstream proxy (if fabio itself is placed behind proxy). In this case i should have two X-Forwarded-*** headers, one from upstream proxy and another one from fabio.

magiconair added a commit that referenced this issue Jun 6, 2017
This patch adds the X-Forwarded-Prefix header to
upstream requests which contains the unmodified
url path from the original request.

Fixes #304
@magiconair
Copy link
Contributor

@avarabyeu pushed a change with test. If you could verify that it works for you then I'll merge it and include it in the next release which I'll roll this week.

@avarabyeu
Copy link
Author

avarabyeu commented Jun 7, 2017

@magiconair Just checked it. Seems like i didn't understand your question about original request path :) Header is added, but value should contain only the part that was truncated by proxy.
For example:
We have registered service with the following params: urlprefix-/myprefix opts strip=/myprefix
I'm executing some GET /myprefix/foo/bar
In current fix x-forwarded-prefix: /myprefix/foo/bar, but the correct value is just /value

Also, it should be added only in case prefix is being stripped.

btw, thanks a lot for prompt answers!

@magiconair
Copy link
Contributor

/value or /foo/bar ?

@magiconair
Copy link
Contributor

Ah, you want the stripped prefix to be in the header, e.g. X-Forwarded-Prefix: /myprefix

magiconair added a commit that referenced this issue Jun 7, 2017
@magiconair
Copy link
Contributor

@avarabyeu I've pushed an update to the branch. Can you check, please?

@avarabyeu
Copy link
Author

@magiconair Checked. Works as expected! Thank you very much, looking forward for the release.

@magiconair magiconair added this to the 1.5.0 milestone Oct 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants