how to trigger "proxy_next_upstream invalid_header"?

Roman Arutyunyan arut at
Thu Jan 25 12:22:29 UTC 2018

Hi Jeffrey,

On Thu, Jan 25, 2018 at 05:41:50PM +0800, Jeffrey 'jf' Lim wrote:
> This is more of a curiosity thing, I guess, than anything else, but...
> how do you trigger an "proxy_next_upstream invalid_header" when
> testing?
> I've tried basically sending random text from an upstream ('nc -l')...
> but nginx holds on to the connection and ends up triggering a
> "timeout" instead. If I send random text, and then close the
> connection, the random text still gets sent to the client, and no next
> peer is tried.

The easiest way is to send the status line + header bigger than
proxy_buffer_size bytes.  Another way is to send a null byte somewhere in the
response header.  You can also try sending broken line and header termination:
CR followed by a non-LF byte.

Roman Arutyunyan

More information about the nginx mailing list