Skip to content

forward

forward provides classic HTTP forward proxying for absolute-URI requests.

It is intentionally scoped to HTTP forwarding only.

CONNECT is handled by the separate connect package.

Use it for

  • clients configured to use your app as an HTTP proxy
  • traffic capture tools
  • forward-proxy flows where you want custom request/response mutation and neutral observation

Main entry point

go
handler := forward.New(forward.Options{
  ForwardedHeaders: proxyhttp.ForwardedHeaderConfig{
    ClientIP: "203.0.113.10",
    Proto:    "http",
    Via:      "proxykit",
  },
})

Important options

OptionMeaning
RoundTripperCustom transport
MutateRequestRequest mutation before forwarding
MutateResponseResponse mutation before returning to client
HooksShared observation hooks
ObserveRequestPredicate to suppress observation
ForwardedHeadersStandard forwarded header policy
SampleRequestBodyBytesObserved request body sample limit
SampleResponseBodyBytesObserved response body sample limit

Important behavior

  • requires an absolute request URL
  • rejects CONNECT
  • strips hop-by-hop headers
  • applies forwarding headers explicitly instead of implicitly hiding policy in the transport

Released under the Apache 2.0 License.