Nginx behind a reverse proxy sending 499
Maxim Dounin
mdounin at mdounin.ru
Mon Jan 12 14:05:18 UTC 2015
Hello!
On Sun, Jan 11, 2015 at 01:37:31AM -0500, ppwm wrote:
> To debug the issue further, I wrote a simple Java based HTTP client. This
> client would open a socket to the nginx server, write the request line (GET
> / HTTP/1.1), write the host header, write the Connection:close header and
> commit the request. While committing the write the CRLF character twice.
>
> In this setup, I tested by having a proxy pass to www.google.com and not
> having a proxy pass (nginx servers the default index.html.
>
> If there is no proxy pass, nginx never gives a 499 status code. Even if I do
> Socket.shutdownOutput(), nginx give a valid 200 response. This is
> irrespective of the Connection header (keepalive/close).
>
> If there is proxy pass, I get a valid response if I don't do
> Socket.shutdownOutput(). But if I do Socket.shutdownOutput(), I get 499
> irrespective of Connection header (keepalive/close). This implies that nginx
> is treating client's Socket.shutdownOutput() as client closing the
> connection despite all data being written to the socket.
In HTTP, it's generally a bad idea to shutdown the socket before
you've got the response. While not strictly prohibited, the
server will likely think that the client bored waiting for a
response and closed the connection, so there is no need to return
any response. Google for something like "http tcp half-close" for
more details.
The "proxy_ignore_client_abort" directive can be used if you want
nginx to be compatible with such clients for some reason, see
here:
http://nginx.org/r/proxy_ignore_client_abort
--
Maxim Dounin
http://nginx.org/
More information about the nginx
mailing list