alibaba / higress

🤖 AI Gateway | AI Native API Gateway
https://higress.io
Apache License 2.0
3.27k stars 516 forks source link

实现和 nginx proxy_redirect 功能等价的 wasm 插件(Implement A wasm plugin that the functional equivalent of nginx proxy_redirect) #61

Open dspo opened 2 years ago

dspo commented 2 years ago

Why do you need it?

Is your feature request related to a problem? Please describe in details

我有如下的路由

[{
    "match": {
        "PathSpecifier": {
            "Prefix": "/web/"
        }
    },
    "Action": {
        "Route": {
            "ClusterSpecifier": {
                "Cluster": "my-web"
            },
            "prefix_rewrite": "/",
            "HostRewriteSpecifier": {
                "AutoHostRewrite": {}
            }
        }
    }
},
{
    "match": {
        "PathSpecifier": {
            "Prefix": "/web"
        }
    },
    "Action": {
        "Route": {
            "ClusterSpecifier": {
                "Cluster": "my-web"
            },
            "prefix_rewrite": "/",
            "HostRewriteSpecifier": {
                "AutoHostRewrite": {}
            }
        }
    }
}]

假设请求 {gateway-domain}/web/abc , 上游服务 my-web 返回 302 Found location: /abc/ . 此时如果 envoy 不处理该响应的话, 浏览器就会访问 {gateway-domain}/abc/ 了.

对标 Nginx http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_redirect

How could it be?

A clear and concise description of what you want to happen. You can explain more about input of the feature, and output of it.

envoy 要么内部处理该重定向, 自动请求新的地址, 将正确结果返回客户端, 要么修改 location 字段后再返回给客户端.

Other related information

Add any other context or screenshots about the feature request here.

johnlanni commented 2 years ago

内部重定向是支持的:https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#envoy-v3-api-msg-config-route-v3-internalredirectpolicy