ProxyAuth / Security

Headers ProxyAuth never relays: hop-by-hop stripping, request smuggling and the WebSocket consequence

ProxyAuthSecurity / HTTPUpdated on 2026-09-18

Some HTTP headers describe the message. Others describe the connection the message happens to be travelling on. A proxy sits between two connections, so copying the second kind across is meaningless at best — and at worst, it is how two HTTP implementations end up disagreeing about where one request ends and the next begins.

The list

These are stripped from every request before it reaches the backend, and from every response before it reaches the client:

Connection            Keep-Alive
Content-Length        Proxy-Connection
Transfer-Encoding     Proxy-Authenticate
TE                    Proxy-Authorization
Trailer
Upgrade

RFC 9110 §7.6.1 calls these connection-specific: each hop is expected to generate its own framing based on how it actually sends the message. ProxyAuth re-serialises every body it forwards, so it emits its own Content-Length or chunked framing and discards whatever arrived.

This is not configurable, on purpose.

What it protects against

Request smuggling works by sending a request whose length two parsers read differently. The classic shape carries both headers:

POST /public HTTP/1.1
Host: app.example.com
Content-Length: 44
Transfer-Encoding: chunked

0

GET /admin HTTP/1.1
Host: app.example.com

If a proxy honours Transfer-Encoding and relays the bytes verbatim, while the backend honours Content-Length — or the other way round — one side sees one request and the other sees two. The second one, GET /admin, was never seen by any access check at the proxy. It arrives at the backend looking like it came through the gate.

Detecting every variant of that ambiguity is a losing game. ProxyAuth removes the ambiguity instead: the framing headers are dropped, the body is read as one message, and new framing is generated for the backend. There is no second request left to smuggle.

The one exception: HEAD

A response to HEAD keeps the backend’s Content-Length. The body is empty by definition, so regenerating the header would produce 0 — but a client issuing HEAD is asking precisely how large the matching GET would be. Both proxy paths — direct and through an egress proxy — behave identically here, so HEAD never answers differently depending on routing.

The consequence: WebSocket does not pass through

A WebSocket handshake is an ordinary HTTP request carrying:

Connection: Upgrade
Upgrade: websocket

Both headers are on the list. They are removed, the backend sees a normal request it has no reason to upgrade, and the connection never becomes a WebSocket. There is no setting to change this: supporting WebSocket means terminating the upgrade in the proxy, not passing headers along.

Today, the practical layout is to keep WebSocket endpoints behind something that handles the upgrade itself, on its own hostname or port, and route everything else through ProxyAuth:

app.example.com      → ProxyAuth → backend (HTTP)
ws.example.com       → WebSocket-aware terminator → backend (WS)

If the WebSocket endpoint needs authentication, have it validate something it can check on its own — for example a short-lived token the HTTP side issues — rather than relying on headers that never reach it.

Identity headers: stripped for a different reason

Another group never reaches the backend as the client sent them. Not because of framing, but because ProxyAuth asserts them itself:

  • X-User, X-User-Roles, X-User-Groups
  • and, when forward_proxy_headers is on, Host (rewritten), X-Forwarded-Host, X-Forwarded-Proto, X-Real-IP, X-Forwarded-For

Client-supplied copies of the forwarding headers are removed regardless of forward_proxy_headers. So a backend that trusts X-User or X-Real-IP cannot be fed a chosen value by a caller who simply sets them:

# the backend still receives the verified identity, not "admin"
curl https://app.example.com/app \
  -H "Authorization: Bearer $TOKEN" \
  -H "X-User: admin" \
  -H "X-Real-IP: 127.0.0.1"

X-Real-IP and X-Forwarded-For are filled with the resolved client address — the same resolution trust_proxy_forward_for governs for rate limiting and IP checks — never with a blind copy of the request.

And Content-Encoding

The client’s Content-Encoding is not forwarded either. It describes the body as it was received, and the body reaching the backend has already been decoded. Announcing an encoding the bytes no longer carry makes the backend fail to decode them. This is exactly what broke git clone against a proxied git forge until it was fixed: git gzips its upload-pack request.

What this means for a backend developer

  • You can trust X-User, X-User-Roles and X-User-Groups on a route with required_login, provided the backend is only reachable through ProxyAuth. Bind it to 127.0.0.1 or a private interface.
  • You can trust X-Real-IP with forward_proxy_headers: true.
  • Do not expect Connection, Upgrade, TE or Trailer semantics to survive the hop.
  • Do not plan a WebSocket endpoint behind ProxyAuth yet.

Regenerate framing instead of relaying it, and assert identity instead of forwarding it. Both rules remove a disagreement rather than trying to detect it — which is the only kind of fix that holds against a class of attack as inventive as request smuggling.