Skip to content

router: auto_host_rewrite_header support#7220

Merged
mattklein123 merged 4 commits intoenvoyproxy:masterfrom
bartebor:auto_host_rewrite_header
Jun 14, 2019
Merged

router: auto_host_rewrite_header support#7220
mattklein123 merged 4 commits intoenvoyproxy:masterfrom
bartebor:auto_host_rewrite_header

Conversation

@bartebor
Copy link
Copy Markdown
Contributor

Description: Make it possible to substitute upstream's request host/:authority header with value of any (downstream or custom) header. This allows for efficient implementation of more involving deployments with specially configured downstream load balancers.
Risk Level: Low, does not change default behaviour
Testing: Unit tests added
Docs Changes: Description in proto file
Release Notes: Updated
Fixes #6486

Signed-off-by: Bartosz Borkowski <bartebor@wp.pl>
Copy link
Copy Markdown
Member

@zuercher zuercher left a comment

Choose a reason for hiding this comment

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

Thanks! This needs some minor changes, but otherwise looks good.


JSON_UTIL_SET_STRING(json_route, *action, prefix_rewrite);

int host_rewrite_options = 0;
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.

Please revert this file. We no longer add new features to the v1 API.

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.

File reverted.

"prefix_rewrite" : {"type" : "string"},
"host_rewrite" : {"type" : "string"},
"auto_host_rewrite" : {"type" : "boolean"},
"auto_host_rewrite_header" : {"type" : "string"},
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.

Likewise, this schema is for the v1 api and should be reverted.

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.

File reverted.

if (header != nullptr) {
absl::string_view headerValue = header->value().getStringView();
if (!headerValue.empty()) {
headers.Host()->value(std::string(headerValue));
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.

You can leave out the temporary std::string and just pass headerValue directly to
HeaderEntry::value(absl::string_view) which will copy the string.

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.

Fixed.

Signed-off-by: Bartosz Borkowski <bartebor@wp.pl>
@bartebor
Copy link
Copy Markdown
Contributor Author

@zuercher, thanks for the review!

zuercher
zuercher previously approved these changes Jun 11, 2019
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM with tiny nit. Thank you!

/wait

} else if (auto_host_rewrite_header_) {
Http::HeaderEntry* header = headers.get(*auto_host_rewrite_header_);
if (header != nullptr) {
absl::string_view headerValue = header->value().getStringView();
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.

nit: header_value

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.

My Java background is showing... fixed.

bartebor added 2 commits June 14, 2019 10:06
…eader

Signed-off-by: Bartosz Borkowski <bartebor@wp.pl>
Signed-off-by: Bartosz Borkowski <bartebor@wp.pl>
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks!

@mattklein123 mattklein123 merged commit 2d33ea0 into envoyproxy:master Jun 14, 2019
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.

Upstream request header modification

3 participants