You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import (
"github.com/valyala/fasthttp"
)
var proxyClient = &fasthttp.HostClient{
Addr: "upstream.host:port",
// set other options here if required - most notably timeouts.
}
func ReverseProxyHandler(ctx *fasthttp.RequestCtx) {
req := &ctx.Request
resp := &ctx.Response
prepareRequest(req)
if err := proxyClient.Do(req, resp); err != nil {
ctx.Logger().Printf("error when proxying the request: %s", err)
}
postprocessResponse(resp)
}
func prepareRequest(req *fasthttp.Request) {
// do not proxy "Connection" header.
req.Header.Del("Connection")
// strip other unneeded headers.
// alter other request params before sending them to upstream host
// req.SetHost(upstream.host)
}
func postprocessResponse(resp *fasthttp.Response) {
// do not proxy "Connection" header
resp.Header.Del("Connection")
// strip other unneeded headers
// alter other response data if needed
}
func main() {
if err := fasthttp.ListenAndServe(":8080", reverseProxyHandler); err != nil {
log.Fatalf("error in fasthttp server: %s", err)
}
}
fasthttp.HostClient Do (function): Crash when forwarding big file (> 2GB)
The text was updated successfully, but these errors were encountered:
fasthttp.HostClient Do (function): Crash when forwarding big file (> 2GB)
The text was updated successfully, but these errors were encountered: