diff --git a/docs/07.Reference/7.02.Filters.md b/docs/07.Reference/7.02.Filters.md index 59d1e5ee1d..408a7e612a 100644 --- a/docs/07.Reference/7.02.Filters.md +++ b/docs/07.Reference/7.02.Filters.md @@ -246,6 +246,36 @@ filters: name: proxy ``` +The following example demonstrates a forward proxy setup. Requests directed to 'example.com' will be forwarded, while all other requests will be denied. It's important to note that when operating a forward proxy, the paths attribute in the `HTTPServer` rule should be left empty. This is because, for HTTPS requests, the client initiates a `CONNECT` request which does not include a path. + +```yaml +kind: HTTPServer +name: httpserver +port: 8088 +keepAlive: true +https: false +rules: + - host: 'example.com' + paths: + - backend: pipeline-forward + +--- + +name: pipeline-forward +kind: Pipeline + +filters: +- name: forward-proxy + kind: SimpleHTTPProxy + serverMaxBodySize: -1 +``` + +To test this forward proxy configuration, use the following command: + +```bash +https_proxy=http://127.0.0.1:8088 http_proxy=http://127.0.0.1:8088 curl https://example.com +``` + ### Configuration | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | diff --git a/pkg/filters/proxies/httpproxy/pool.go b/pkg/filters/proxies/httpproxy/pool.go index 6ed24f3c5e..690861d308 100644 --- a/pkg/filters/proxies/httpproxy/pool.go +++ b/pkg/filters/proxies/httpproxy/pool.go @@ -512,7 +512,7 @@ func (sp *ServerPool) buildResponse(spCtx *serverPoolContext) (err error) { maxBodySize = sp.proxy.spec.ServerMaxBodySize } if err = resp.FetchPayload(maxBodySize); err != nil { - logger.Errorf("%s: failed to fetch response payload: %v", sp.Name, err) + logger.Errorf("%s: failed to fetch response payload: %v, please consider to set serverMaxBodySize of Proxy to -1.", sp.Name, err) body.Close() return err } diff --git a/pkg/filters/proxies/httpproxy/simplehttpproxy.go b/pkg/filters/proxies/httpproxy/simplehttpproxy.go index 4641931d25..02bf9a985a 100644 --- a/pkg/filters/proxies/httpproxy/simplehttpproxy.go +++ b/pkg/filters/proxies/httpproxy/simplehttpproxy.go @@ -282,7 +282,7 @@ func (shp *SimpleHTTPProxy) Handle(ctx *context.Context) (result string) { maxBodySize := shp.spec.ServerMaxBodySize if err = httpResp.FetchPayload(maxBodySize); err != nil { - logger.Errorf("%s: failed to fetch response payload: %v", shp.Name(), err) + logger.Errorf("%s: failed to fetch response payload: %v, please consider to set serverMaxBodySize of SimpleHTTPProxy to -1.", shp.Name(), err) return resultServerError }