Implement host_rewrite_path option (#12440)

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.

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>

Mirrored from https://github.com/envoyproxy/envoy @ 374dca7905fc048be74169a7655d0462606555ad
master-ci-test
data-plane-api(CircleCI) 5 years ago
parent 6ee160427d
commit 22601a9e96
  1. 19
      envoy/config/route/v3/route_components.proto
  2. 19
      envoy/config/route/v4alpha/route_components.proto

@ -545,7 +545,7 @@ message CorsPolicy {
core.v3.RuntimeFractionalPercent shadow_enabled = 10;
}
// [#next-free-field: 35]
// [#next-free-field: 36]
message RouteAction {
option (udpa.annotations.versioning).previous_message_type = "envoy.api.v2.route.RouteAction";
@ -890,6 +890,23 @@ message RouteAction {
// must come from trusted source.
string host_rewrite_header = 29
[(validate.rules).string = {well_known_regex: HTTP_HEADER_NAME strict: false}];
// Indicates that during forwarding, the host header will be swapped with
// the result of the regex substitution executed on path value with query and fragment removed.
// This is useful for transitioning variable content between path segment and subdomain.
//
// For example with the following config:
//
// .. code-block:: yaml
//
// host_rewrite_path_regex:
// pattern:
// google_re2: {}
// regex: "^/(.+)/.+$"
// substitution: \1
//
// Would rewrite the host header to `envoyproxy.io` given the path `/envoyproxy.io/some/path`.
type.matcher.v3.RegexMatchAndSubstitute host_rewrite_path_regex = 35;
}
// Specifies the upstream timeout for the route. If not specified, the default is 15s. This

@ -547,7 +547,7 @@ message CorsPolicy {
core.v4alpha.RuntimeFractionalPercent shadow_enabled = 10;
}
// [#next-free-field: 35]
// [#next-free-field: 36]
message RouteAction {
option (udpa.annotations.versioning).previous_message_type = "envoy.config.route.v3.RouteAction";
@ -886,6 +886,23 @@ message RouteAction {
// must come from trusted source.
string host_rewrite_header = 29
[(validate.rules).string = {well_known_regex: HTTP_HEADER_NAME strict: false}];
// Indicates that during forwarding, the host header will be swapped with
// the result of the regex substitution executed on path value with query and fragment removed.
// This is useful for transitioning variable content between path segment and subdomain.
//
// For example with the following config:
//
// .. code-block:: yaml
//
// host_rewrite_path_regex:
// pattern:
// google_re2: {}
// regex: "^/(.+)/.+$"
// substitution: \1
//
// Would rewrite the host header to `envoyproxy.io` given the path `/envoyproxy.io/some/path`.
type.matcher.v4alpha.RegexMatchAndSubstitute host_rewrite_path_regex = 35;
}
// Specifies the upstream timeout for the route. If not specified, the default is 15s. This

Loading…
Cancel
Save