I tried to write a web service as a joke today at http://dont-tread-on-memes.controversial.io. It's a flask app that serves fairly large images. The Flask app works well on its own, as does an independent uWSGI server, but when I try to plug uWSGI into NGINX via uwsgi_pass
, suddenly every other request is truncated at 9.99KB across browsers.
After reading about similar truncation with proxy_pass
I tried:
- Setting
uwsgi_buffering
tooff
in my config file - Increasing the buffer size to
1024k
withuwsgi_buffers 1024 1024k; uwsgi_buffer_size 1024k;
sendfile: off
- Checking buffer file permissions (all the files in
/var/lib/uwsgi
are owned by thewww-data
user and thewww-data
group, so I think my permissions are good.)
I'm left with my current config, which still exhibits the issue:
server {
listen 80;
server_name dont-tread-on-memes.controversial.io;
location / {
include uwsgi_params;
uwsgi_pass unix:/var/www/dont-tread-on-memes/dont_tread_on_memes.sock;
uwsgi_buffers 1024 1024k;
uwsgi_buffer_size 1024k;
}
}
The strangest part is that this issue appears only on every second request. It has to be something to do with NGINX cache, since I'm not using multiple NGINX instances or anything. Yet it has to be something to do with my NGINX config, since uWSGI running on its own does not exhibit the issue.
Any thoughts on what could be causing this issue, and how to fix it?