mirror of
https://github.com/caddyserver/caddy.git
synced 2026-03-07 09:35:34 -05:00
reverseproxy: query escape request urls when proxy protocol is enabled (#7537)
This commit is contained in:
parent
f145bce553
commit
2ab043b890
@ -1278,7 +1278,12 @@ func (h *Handler) directRequest(req *http.Request, di DialInfo) {
|
||||
// add client address to the host to let transport differentiate requests from different clients
|
||||
if ppt, ok := h.Transport.(ProxyProtocolTransport); ok && ppt.ProxyProtocolEnabled() {
|
||||
if proxyProtocolInfo, ok := caddyhttp.GetVar(req.Context(), proxyProtocolInfoVarKey).(ProxyProtocolInfo); ok {
|
||||
reqHost = proxyProtocolInfo.AddrPort.String() + "->" + reqHost
|
||||
// encode the request so it plays well with h2 transport, it's unnecessary for h1 but anyway
|
||||
// The issue is that h2 transport will use the address to determine if new connections are needed
|
||||
// to roundtrip requests but the without escaping, new connections are constantly created and closed until
|
||||
// file descriptors are exhausted.
|
||||
// see: https://github.com/caddyserver/caddy/issues/7529
|
||||
reqHost = url.QueryEscape(proxyProtocolInfo.AddrPort.String() + "->" + reqHost)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user