From 696e2e418215bf15e213af6a06b9b50898e40e81 Mon Sep 17 00:00:00 2001 From: "data-plane-api(Azure Pipelines)" Date: Tue, 28 Feb 2023 17:30:11 +0000 Subject: [PATCH] custom response: Add ResponseConfig to redirect policy (#25441) Signed-off-by: pcrao Mirrored from https://github.com/envoyproxy/envoy @ 283cd349809ca01eb1a81ef948bed6d47bec4ba0 --- .../custom_response/redirect_policy/v3/BUILD | 1 + .../redirect_policy/v3/redirect_policy.proto | 45 ++++++++++--------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/envoy/extensions/http/custom_response/redirect_policy/v3/BUILD b/envoy/extensions/http/custom_response/redirect_policy/v3/BUILD index e9b556d6..d0a7c688 100644 --- a/envoy/extensions/http/custom_response/redirect_policy/v3/BUILD +++ b/envoy/extensions/http/custom_response/redirect_policy/v3/BUILD @@ -7,6 +7,7 @@ licenses(["notice"]) # Apache 2 api_proto_package( deps = [ "//envoy/config/core/v3:pkg", + "//envoy/config/route/v3:pkg", "@com_github_cncf_udpa//udpa/annotations:pkg", "@com_github_cncf_udpa//xds/annotations/v3:pkg", ], diff --git a/envoy/extensions/http/custom_response/redirect_policy/v3/redirect_policy.proto b/envoy/extensions/http/custom_response/redirect_policy/v3/redirect_policy.proto index 15ff1a3a..73cf7ed7 100644 --- a/envoy/extensions/http/custom_response/redirect_policy/v3/redirect_policy.proto +++ b/envoy/extensions/http/custom_response/redirect_policy/v3/redirect_policy.proto @@ -4,6 +4,7 @@ package envoy.extensions.http.custom_response.redirect_policy.v3; import "envoy/config/core/v3/base.proto"; import "envoy/config/core/v3/extension.proto"; +import "envoy/config/route/v3/route_components.proto"; import "google/protobuf/wrappers.proto"; @@ -26,28 +27,30 @@ option (xds.annotations.v3.file_status).work_in_progress = true; // upstream. // [#next-free-field: 7] message RedirectPolicy { - // [#comment: TODO(pradeepcrao): Add the ability to specify the full uri, or just host or - // path rewrite for the redirection in the same vein as - // config.route.v3.RedirectAction] - // The host that will serve the custom response. - // - // Example: - // - // .. code-block:: yaml - // - // uri: https://www.mydomain.com - // - string host = 1 [(validate.rules).string = {min_len: 1}]; + oneof redirect_action_specifier { + option (validate.required) = true; - // The path for the custom response. - // - // Example: - // - // .. code-block:: yaml - // - // path: /path/to/503_response.txt - // - string path = 2 [(validate.rules).string = {min_len: 1}]; + // The Http URI to redirect the original request to, to get the custom + // response. + // It should be a full FQDN with protocol, host and path. + // + // Example: + // + // .. code-block:: yaml + // + // uri: https://www.mydomain.com/path/to/404.txt + // + string uri = 1 [(validate.rules).string = {min_len: 1}]; + + // Specify elements of the redirect url individually. + // Note: Do not specify the `response_code` field in `redirect_action`, use + // `status_code` instead. + // The following fields in `redirect_action` are currently not supported, + // and specifying them will cause the config to be rejected: + // - `prefix_rewrite` + // - `regex_rewrite` + config.route.v3.RedirectAction redirect_action = 2; + } // The new response status code if specified. This is used to override the // status code of the response from the new upstream if it is not an error status.