Skip to content

Commit

Permalink
update error msg (#1134)
Browse files Browse the repository at this point in the history
  • Loading branch information
suchen-sci authored Nov 10, 2023
1 parent a146612 commit be99c1b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
30 changes: 30 additions & 0 deletions docs/07.Reference/7.02.Filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
| ---- | ---- | ----------- | -------- |
Expand Down
2 changes: 1 addition & 1 deletion pkg/filters/proxies/httpproxy/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/filters/proxies/httpproxy/simplehttpproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit be99c1b

Please sign in to comment.