nginx silently drops response body of POST depending on its length

Roberto De Ioris roberto at unbit.it
Mon May 9 09:41:42 MSD 2011


> I've come across an incredibly weird problem with POST responses using
> nginx 1.0.1 and uWSGI 0.9.7.2 on CentOS 5.6.
>
> uWSGI successfully sends the response body to nginx, but nginx seems to
> ignore it if both (1) the request method is POST, and (2) the response
> length is less than 4052 bytes. The issue doesn't occur when serving
> directly using `uwsgi --http`, so I'm pretty sure the problem is
> something to do with nginx.
>
> To explain things in code, this Python results in the desired response:
>
> ....def app_uwsgi(environ, start_response):
> ........start_response('200 OK', [('Content-type', 'text/html')])
> ........return [b'x' * 4052]
>
> while this results in zero bytes being sent to the client for POST
> requests:
>
> ....def app_uwsgi(environ, start_response):
> ........start_response('200 OK', [('Content-type', 'text/html')])
> ........return [b'x' * 4051]
>
> I stripped down to a minimal nginx.conf, and the issue still occurs:
>
> ....events {
> ........worker_connections  1024;
> ....}
>
> ....http {
> ........upstream uwsgi_connect {
> ............server  127.0.0.1:39275;
> ........}
>
> ........server {
> ............listen       20101;
> ............server_name  domain.net;
>
> ............location / {
> ................uwsgi_pass  uwsgi_connect;
> ................include     uwsgi_params;
> ............}
> ........}
> ....}
>
>


Be sure to read POST body in your WSGI app if Content-Length > 0,
otherwise your socket queue will get clobbered (nginx will receive a close
when there is still data available in the queue)

-- 
Roberto De Ioris
http://unbit.it



More information about the nginx mailing list