Repository navigation
Support for x-forwarded-host header. - #18639
Conversation
If, for a request, the host/authority header is changed when the request is proxied, set the x-forwarded-host header as: x-forwarded-host = append(x-forwarded-host, host) Signed-off-by: Arun Olappamanna Vasudevan <[email protected]>
|
Hi @arun-vasudev, welcome and thank you for your contribution. We will try to review your Pull Request as quickly as possible. In the meantime, please take a look at the contribution guidelines if you have not done so already. |
1. Initialize append_xfh_ in RouteEntry implementation. 2. Version history is not in alphabetical order. 3. Minor typo fix the documentation for append_x_forwarded_host. 4. Fix the cross-references to append_x_forwarded_host. Signed-off-by: Arun Olappamanna Vasudevan <[email protected]>
e6c5cab to
72bb91e
Compare
Signed-off-by: Arun Olappamanna Vasudevan <[email protected]>
Signed-off-by: Arun Olappamanna Vasudevan <[email protected]>
Signed-off-by: Arun Olappamanna Vasudevan <[email protected]>
Signed-off-by: Arun Olappamanna Vasudevan <[email protected]>
Signed-off-by: Arun Olappamanna Vasudevan <[email protected]>
Signed-off-by: Arun Olappamanna Vasudevan <[email protected]>
Signed-off-by: Arun Olappamanna Vasudevan <[email protected]>
|
/assign-from @envoyproxy/first-pass-reviewers |
|
@envoyproxy/first-pass-reviewers assignee is @rojkov |
rojkov
left a comment
There was a problem hiding this comment.
Thank you for working on this! Looks good, only one question to clarify.
| if (hostname.empty()) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Doesn't it change the current default behavior for empty hostnames?
If hostname can never be empty then, perhaps, it's better to ASSERT() it to catch bugs.
There was a problem hiding this comment.
That makes sense! We can retain the original behavior by removing the check. I do not think we can ASSERT() because host_rewrite_path_regex_->replaceAll in source/common/router/config_impl.cc could potentially return an empty string.
There was a problem hiding this comment.
I see. Alright then. Could you please extend the unit test to include the case of empty hostname?
* Retain default behavior in updateAuthority. * Enumerate all host rewrite options in the documentation for append_x_forwarded_host. Signed-off-by: Arun Olappamanna Vasudevan <[email protected]>
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
| oneof host_rewrite_specifier { | ||
| // Indicates that during forwarding, the host header will be swapped with | ||
| // this value. | ||
| // this value. Using this option may manipulate the |
There was a problem hiding this comment.
s/may manipulate/will append/g (here and other cases).
|
/wait |
…ifier doc. Signed-off-by: Arun Olappamanna Vasudevan <[email protected]>
rojkov
left a comment
There was a problem hiding this comment.
Thanks! Looks very good. The CI checks need to be fixed:
RSTChecker ERROR [current_version] (docs/root/version_history/current.rst:70) Version history not in alphabetical order (router vs oauth filter): please check placement of line
* oauth filter: setting IdToken and RefreshToken cookies if they are provided by Identity provider along with AccessToken..
To test locally you can run ./tools/code_format/check_format.py fix.
|
/wait |
Signed-off-by: Arun Olappamanna Vasudevan <[email protected]>
3d69e13 to
527ea51
Compare
|
It seems to be failing while trying to download googleapis: Is this a known issue? It'll be great if someone can help out here. @htuch @rojkov |
Signed-off-by: Arun Olappamanna Vasudevan <[email protected]>
cf713a5 to
8b4f7d0
Compare
|
It seems to be a transient issue. The checks look good now. |
rojkov
left a comment
There was a problem hiding this comment.
Thank you! Looks good modulo small nitpick.
| x-forwarded-host | ||
| ---------------- | ||
|
|
||
| The *x-forwarded-host* header is a standard proxy header which indicates the original host |
There was a problem hiding this comment.
Nit: Technically there's no standard for this header. The standard specifies Forwarded instead.
| The *x-forwarded-host* header is a standard proxy header which indicates the original host | |
| The *x-forwarded-host* header is a de-facto standard proxy header which indicates the original host |
Signed-off-by: Arun Olappamanna Vasudevan <[email protected]>
If, for a request, the host/authority header is changed when the
request is proxied, set the x-forwarded-host header as:
x-forwarded-host = append(x-forwarded-host, host)
Signed-off-by: Arun Olappamanna Vasudevan [email protected]
Commit Message: Support for x-forwarded-host header.
Additional Description:
If, for a request, the host/authority header is changed when the
request is proxied, set the x-forwarded-host header as:
x-forwarded-host = append(x-forwarded-host, host)
Risk Level: Low
Testing: unit test and manual testing
Docs Changes:
Added x-forwarded-host header in HTTP header manipulation
(configuration/http/http_conn_man/headers).
Under the host_rewrite options in route_components.proto
(in v3), added that when host is rewritten, the XFH header is
appended with the original value of host header if append_x_forwarded_host
option is set.
Release Notes: router: added support for x-forwarded-host header.
Platform Specific Features: N/A
Fixes #5940
API Considerations: append_x_forwarded_host in route options