Using single persistent socket to send subrequests

Francis Daly francis at
Tue Feb 1 09:24:47 UTC 2022

On Wed, Jan 26, 2022 at 07:18:02AM +0000, Devashi Tandon wrote:

Hi there,

You may or may not have seen a parallel mail with the Subject:
auth_request sub requests not using upstream keepalive.

> I tried with clearing the connections header but NGINX is still sending
> the 5th response through a new source port. Let me give a more detailed
> configuration we have. Just to inform you, we have our own auth module
> instead of using the NGINX auth module. We call ngx_http_post_request to
> post subrequests and the code is almost the same as that of auth module.

A response there indicates that for the stock nginx auth_request,
if there is any body content in the response, that leads to the tcp
connection being closed.

If your module does the same, then you probably want to either make sure
that the auth module response has no body; or make sure that your auth
module reads the response body.

In very light testing with "keepalive 3;", I saw the same tcp connection
being re-used for subsequent requests (from the same client) when the
auth response had no body; and new connections being used when the auth
response had a body.

So I suspect that that is the piece that is missing in your setup.

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list