Commit 54aefec2 authored by qiuqunfeng's avatar qiuqunfeng
Browse files

Refactor WafLogController to utilize the new proxy request rewriting method,...

Refactor WafLogController to utilize the new proxy request rewriting method, improving URL handling and ensuring correct host assignment for WAF log requests.
parent bc8bc048
...@@ -31,10 +31,9 @@ func (c *WafLogController) WafLogProxy(ctx *gin.Context) { ...@@ -31,10 +31,9 @@ func (c *WafLogController) WafLogProxy(ctx *gin.Context) {
log.Info().Msgf("remoteUrl: %s", remoteUrl.String()) log.Info().Msgf("remoteUrl: %s", remoteUrl.String())
proxy := httputil.NewSingleHostReverseProxy(remoteUrl) proxy := httputil.NewSingleHostReverseProxy(remoteUrl)
proxy.Director = func(req *http.Request) { proxy.Rewrite = func(req *httputil.ProxyRequest) {
req.URL.Scheme = remoteUrl.Scheme req.Out.URL.Path = strings.Replace(req.In.URL.Path, "/api/v2/containerSec/waf", "/api/v2/waf", 1)
req.URL.Path = strings.Replace(req.URL.Path, "/api/v2/containerSec/waf", "/api/v2/waf", 1) req.Out.Host = remoteUrl.Host
req.URL.RawQuery = ctx.Request.URL.RawQuery
} }
proxy.ServeHTTP(ctx.Writer, ctx.Request) proxy.ServeHTTP(ctx.Writer, ctx.Request)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment