I am using Python, Flask, uWSGI and NGINX to host a web server. One of the functions involves generating a file for the user which can take up to a minute or two. On this action I keep getting a 504 timeout from NGINX. I tried to change some config variables in /etc/nginx/nginx.conf
like keepalive_timeout
but that didn't work.I also tried to add the following to /etc/nginx/conf.d/timeout.conf
:
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
and then I reloaded with systemctl reload nginx
but it didn't change anything.
How do I increase the length of time before the request times out? Thanks for any help
Add the following directives at the end of the 'http' section to increase the timeout limit to 180 seconds (3 minutes):
http {
<...>
include /etc/nginx/conf.d/.conf;
proxy_send_timeout 180s;
proxy_read_timeout 180s;
fastcgi_send_timeout 180s;
fastcgi_read_timeout 180s;
}
I faced the same problem .. I've found a workaround telling nginx to accept a certain amount of data over the default one. Not trying to manage the timeout itself but changing the amount of data accepted in the transaction did the trick.
server {
client_max_body_size 5M; # or more ^^
}
but it's really not a secured option .. it works, but take care doing this.
moreover if you are using a reverse proxy WSGI gateway (Php for example) .. the underlayrer mechanism may take precedence over that
server {
server_name yourhost;
client_max_body_size 5M;
location / {
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080; # depending on your network conf
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.