Skip to content

wsproxy

wsproxy provides a reusable WebSocket proxy handler with:

  • target resolution
  • optional http/https to ws/wss normalization
  • bidirectional frame forwarding
  • frame and protocol observation hooks
  • optional plaintext fallback for TLS-mismatch targets

Main entry point

go
handler, err := wsproxy.New(wsproxy.Options{
  Resolver: wsproxy.QueryTargetResolver{
    NormalizeScheme: true,
  },
})

Important options

OptionMeaning
ResolverRequired target resolver
ObserveTargetPredicate to suppress observation
HooksWebSocket-specific hook set
HandshakeTimeoutUpstream dial timeout
InsecureTLSSkip upstream TLS verification
AllowPlaintextFallbackRetry wss targets as plaintext when appropriate
BeforeForwardPer-frame forward decision hook
ForwardHeadersSelected request headers to forward upstream
SynthesizeOriginOptionally synthesize an upstream Origin

Why it matters

A lot of proxy libraries treat WebSocket as an afterthought. wsproxy is a first-class package with its own clear scope instead of an awkward branch inside an HTTP proxy object.

Released under the Apache 2.0 License.