-
Notifications
You must be signed in to change notification settings - Fork 543
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
支持nginx的error_page功能 #1612
Comments
目前client请求外部地址需要经过mcpbridges,插件里如果集成外部对象存储的地址,配置起来还怪麻烦的 |
higress 目前扩展了 envoy 的 custom-response filter 的能力,可以实现类似的效果。 例如这个是对“abc”这条路由,配置一个fallback,当触发4xx,5xx时,加上一个 header: 目标的fallback路由上,可以增加一个 header 精确匹配 apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: custom-response-route-abc
namespace: higress-system
spec:
configPatches:
- applyTo: HTTP_ROUTE
match:
context: GATEWAY
routeConfiguration:
vhost:
route:
name: "abc"
patch:
operation: MERGE
value:
typed_per_filter_config:
envoy.filters.http.custom_response:
"@type": type.googleapis.com/udpa.type.v1.TypedStruct
type_url: type.googleapis.com/envoy.extensions.filters.http.custom_response.v3.CustomResponse
value:
with_request_body:
max_request_bytes: 1024000
custom_response_matcher:
matcher_list:
matchers:
- predicate:
or_matcher:
predicate:
- single_predicate:
input:
name: "4xx_response"
typed_config:
"@type": type.googleapis.com/envoy.type.matcher.v3.HttpResponseStatusCodeClassMatchInput
value_match:
exact: "4xx"
- single_predicate:
input:
name: "5xx_response"
typed_config:
"@type": type.googleapis.com/envoy.type.matcher.v3.HttpResponseStatusCodeClassMatchInput
value_match:
exact: "5xx"
on_match:
action:
name: action
typed_config:
"@type": type.googleapis.com/udpa.type.v1.TypedStruct
type_url: type.googleapis.com/envoy.extensions.http.custom_response.redirect_policy.v3.RedirectPolicy
value:
max_internal_redirects: 10
use_original_request_uri: true
keep_original_response_code: false
use_original_request_body: true
only_redirect_upstream_code: false
request_headers_to_add:
- header:
key: "x-higress-fallback-from"
value: "qwen"
append: false
response_headers_to_add:
- header:
key: "x-higress-fallback-from"
value: "qwen"
append: false matcher_list 部分的配置,除了 4xx,5xx 也可以配置精确的状态码,具体可以参考 envoy 的文档。 higress 做的扩展主要是 RedirectPolicy 这个 action 的配置,增加了几个配置项:
|
on_match:
action:
name: action
typed_config:
"@type": type.googleapis.com/udpa.type.v1.TypedStruct
type_url: type.googleapis.com/envoy.extensions.http.custom_response.redirect_policy.v3.RedirectPolicy
value:
uri: https://www.mydomain.com/path/to/404.txt 简单的用例,这样就可以。 可以考虑设计一个 ingress 注解,来实现完整的 nginx error_page 功能 |
Why do you need it?
默认在一些常见的异常页面,比如404, 503等,为了给用户一个好的信息反馈,会单独定制一些页面。nginx支持这块功能使用的配置指令是error_page, 具体用法参见: https://nginx.org/en/docs/http/ngx_http_core_module.html#error_page
How could it be?
具体功能类似nginx的error_page功能,可以配置什么返回码对应哪些页面,这个页面可能是存储在oss,也可能是在某个服务上的。
比如如果页面请求返回404,整体返回404的一个提示页面。
Other related information
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: