Skip to content

Implement host_rewrite_path option#12440

Merged
htuch merged 8 commits intoenvoyproxy:masterfrom
Pchelolo:host_rewrite_path
Aug 11, 2020
Merged

Implement host_rewrite_path option#12440
htuch merged 8 commits intoenvoyproxy:masterfrom
Pchelolo:host_rewrite_path

Conversation

@Pchelolo
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
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.

Petr Pchelko added 3 commits August 3, 2020 16:47
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
Copy Markdown
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>
? absl::optional<Http::LowerCaseString>(Http::LowerCaseString(
route.route().host_rewrite_header()))
: absl::nullopt),
host_rewrite_path_(
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Petr Pchelko added 2 commits August 5, 2020 13:10
Signed-off-by: Petr Pchelko <ppchelko@wikimedia.org>
Signed-off-by: Petr Pchelko <ppchelko@wikimedia.org>
@Pchelolo
Copy link
Copy Markdown
Contributor Author

Merged master in to resolve a conflict.

Signed-off-by: Petr Pchelko <ppchelko@wikimedia.org>
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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