Skip to content

Conversation

@jstangroome
Copy link

By default nginx will send a Connection: close request header to the upstream when proxying which breaks upstream connection keepalives and can introduce latency due to repeated upstream TCP handshakes, and port exhaustion under load due to accumulating TIME_WAIT/CLOSE_WAIT TCP sockets.

To fix upstream keepalives we configure nginx to not send the Connection request header upstream by setting the value to blank.

However, for websocket support, if the Upgrade: websocket request header is present, we must send a Connection: upgrade request header with it to the upstream.

An nginx map allows us to support both within the same location block.

By default nginx will send a `Connection: close` request header to the upstream when proxying which breaks upstream connection keepalives and can introduce latency due to repeated upstream TCP handshakes, and port exhaustion under load due to accumulating `TIME_WAIT`/`CLOSE_WAIT` TCP sockets.

To fix upstream keepalives we configure nginx to not send the `Connection` request header upstream by setting the value to blank.

However, for websocket support, if the `Upgrade: websocket` request header is present, we must send a `Connection: upgrade` request header with it to the upstream.

An nginx `map` allows us to support both within the same `location` block.
@vercel
Copy link

vercel bot commented Jan 22, 2026

@jstangroome is attempting to deploy a commit to the overtrue's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant