[英]How to increase timeout for NGINX?
我正在使用 Python、Flask、uWSGI 和 NGINX 來托管 Web 服務器。 其中一個功能涉及為用戶生成一個文件,這可能需要一兩分鍾。 在此操作中,我不斷收到來自 NGINX 的 504 超時。 我嘗試更改/etc/nginx/nginx.conf
一些配置變量,例如keepalive_timeout
但這不起作用。我還嘗試將以下內容添加到/etc/nginx/conf.d/timeout.conf
:
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
然后我用systemctl reload nginx
重新加載,但它沒有改變任何東西。
如何增加請求超時前的時間長度? 謝謝你的幫助
在“http”部分的末尾添加以下指令以將超時限制增加到 180 秒(3 分鍾):
http {
<...>
include /etc/nginx/conf.d/.conf;
proxy_send_timeout 180s;
proxy_read_timeout 180s;
fastcgi_send_timeout 180s;
fastcgi_read_timeout 180s;
}
來源: https : //support.plesk.com/hc/en-us/articles/115000170354-An-operation-or-a-script-that-takes-more-than-60-seconds-to-complete-fails- on-a-website-hosted-in-Plesk-nginx-504-Gateway-Time-out
我遇到了同樣的問題..我找到了一種解決方法,告訴 nginx 接受一定數量的數據而不是默認數據。 不是試圖管理超時本身,而是改變事務中接受的數據量就成功了。
server {
client_max_body_size 5M; # or more ^^
}
但它真的不是一個安全的選擇......它有效,但要小心這樣做。
此外,如果您使用反向代理 WSGI 網關(例如 Php).. 底層機制可能優先於那個
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
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.