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

Implement host_rewrite_path option #12440

Merged
merged 8 commits into from
Aug 11, 2020
Merged

Conversation

Pchelolo
Copy link
Contributor

@Pchelolo Pchelolo commented Aug 3, 2020

This implements a host_rewrite_path option for rewriting the Host header based on path. See rational in the linked issue.

Note: the regex is executed on the path with query/fragment stripped. This is analogues to what regex_rewrite option is doing.

Commit Message: Implement host_rewrite_path option
Risk Level: Low
Testing: added unit tests
Docs Changes: document the new option in proto file
Release Notes: added to current.rst
Fixes #12430

Signed-off-by: Petr Pchelko ppchelko@wikimedia.org

Signed-off-by: Petr Pchelko <ppchelko@wikimedia.org>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/envoy/.
CC @envoyproxy/api-watchers: FYI only for changes made to api/envoy/.

🐱

Caused by: #12440 was opened by Pchelolo.

see: more, trace.

@dio dio assigned asraa Aug 3, 2020
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@dio dio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comments for docs.

source/common/router/config_impl.cc Outdated Show resolved Hide resolved
Signed-off-by: Petr Pchelko <ppchelko@wikimedia.org>
Signed-off-by: Petr Pchelko <ppchelko@wikimedia.org>
Signed-off-by: Petr Pchelko <ppchelko@wikimedia.org>
@Pchelolo
Copy link
Contributor Author

Pchelolo commented Aug 4, 2020

@dio thank you for the review. Addressed your comments.

@Pchelolo Pchelolo requested a review from dio August 4, 2020 14:22
Signed-off-by: Petr Pchelko <ppchelko@wikimedia.org>
@@ -287,6 +287,13 @@ RouteEntryImplBase::RouteEntryImplBase(const VirtualHostImpl& vhost,
? absl::optional<Http::LowerCaseString>(Http::LowerCaseString(
route.route().host_rewrite_header()))
: absl::nullopt),
host_rewrite_path_(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: suggest using a "regex" in the naming so it's clear this is a regex

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO that would make it less clear what the regex is being executed on. It seems like other options names suggest where the Host header rewrite is coming from, (e.g. host_rewrite_literal, host_rewrite_header) not how the result is constructed.

With host_rewrite_regex you could imaging the regex being exectuted on some other header, or on the original Host name.

Having said that, happy to change if you think regex's better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, you mean host_rewrite_path_regex, not host_rewrite_regex?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha yep, definitely agree that path should be included so it's clear. On my own first glance though the naming didn't line up to my understanding that this was a compiled regex matcher. But no worries either way (header file's got the type anyway)

Copy link
Contributor Author

@Pchelolo Pchelolo Aug 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. changing to host_rewrite_path_regex, thank you.

@asraa asraa assigned dio and unassigned asraa Aug 5, 2020
Signed-off-by: Petr Pchelko <ppchelko@wikimedia.org>
Signed-off-by: Petr Pchelko <ppchelko@wikimedia.org>
@Pchelolo
Copy link
Contributor Author

Merged master in to resolve a conflict.

Signed-off-by: Petr Pchelko <ppchelko@wikimedia.org>
Copy link
Member

@dio dio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Thank you. This requires @envoyproxy/api-shepherds approval.

host_rewrite_path_regex_substitution_(
route.route().has_host_rewrite_path_regex()
? route.route().host_rewrite_path_regex().substitution()
: ""),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually set it as EMPTY_STRING here. But I think we can do cleanup later.

@htuch
Copy link
Member

htuch commented Aug 11, 2020

/lgtm api

@htuch htuch merged commit 374dca7 into envoyproxy:master Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: Introduce host_rewrite_path support in route config
4 participants