I'm using nginx as reverse-proxy to be able to access my Django API and also serve static files. My Django API is using gunicorn.
I have an endpoint allowing a user to download a csv file. I followed the instructions here, Streaming large CSV files: https://docs.djangoproject.com/en/2.2/howto/outputting-csv/
Here is the nginx configuration:
upstream docker-api {
server api;
}
server {
listen 443 ssl;
server_name xxxx.com;
ssl_certificate /path/to/fullchain.pem;
ssl_certificate_key /path/to//privkey.pem;
include /path/to/options-ssl-nginx.conf;
ssl_dhparam /path/to/ssl-dhparams.pem;
location /static {
autoindex on;
alias /static/;
}
location /uploads {
autoindex on;
alias /uploads/;
}
location / {
proxy_pass http://docker-api;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
This is the command I use to launch my gunicorn server:
gunicorn my_api.wsgi -b 0.0.0.0:80 --enable-stdio-inheritance -w 2 -t 180 -k gevent
And when I try to download the file, Gunicorn always timeout my request after 3 minutes. It should not timeout a streaming http response.