-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
feat(proxy/pdk) add support for X-Forwarded-Prefix #5620
Conversation
9439dc8
to
4bb8686
Compare
4bb8686
to
29a0efa
Compare
You are right, but Github also has ignore whitespace when reviewing: |
29a0efa
to
eefeefc
Compare
eefeefc
to
f258542
Compare
Anything more I can do to get this merged? I have reviewed the code, and I think it looks good. @kikito has requested changes, but I am not sure what changes are actually required. |
### Summary Kong currently adds these headers to upstream request: ``` X-Forwarded-For X-Forwarded-Port X-Forwarded-Proto X-Forwarded-Host X-Real-IP ``` @erikgb mentioned that he would like to have `X-Forwarded-Prefix` added on #5602. This PR adds that, and additionally introduces a new PDK function: ```lua local path = kong.request.get_forwarded_path() ``` ### Issues Resolved Close #5602
f258542
to
2f54327
Compare
### Summary The PR #5620 implemented `X-Forwarded-Prefix` wrong. The implementation looks more like proprietary `X-Forwarded-Path`. This commit changes that accordingly. Next commit in this PR will re-introduce X-Forwarded-Prefix correctly. I decided to keep the current behavior as it is already used in some code with PDK `kong.request.get_forwarded_path` (e.g. if the plugin needs to get the original request path, the one that is perhaps rewritten by Kong or a proxy before Kong, perhaps Kong as well).
…warded_prefix ### Summary The PR #5620 implemented `X-Forwarded-Prefix` wrong as reported in these: - #6190 - Kong/kubernetes-ingress-controller#784 - #6132 And also by some other sources. This commit re-implements `X-Forwarded-Prefix`: 1. Is there trusted `X-Forwarded-Prefix` header in request? If yes, then set that as the `X-Forwarded-Prefix` (note: at this point we don't support multi-value `X-Forwarded-Prefix` headers, e.g. appending. We don't support multi-value in `X-Forwarded-Host/-Port/-Proto` either. 2. Has Kong router stripped the prefix of the request URI before proxying, if yes, then set `X-Forwarded-Prefix` to match the stripped prefix. 3. If 1 or 2 didn't set the header, set it to `/`. ### Issues Resolved Fix #6190 Fix Kong/kubernetes-ingress-controller#784 Fix #6132
Summary
Kong currently adds these headers to upstream request:
@erikgb mentioned that he would like to have
X-Forwarded-Prefix
added on #5602.
This PR adds that, and additionally introduces a new PDK function:
Issues Resolved
Close #5602