nginx504超時解決方法


最近部署了一個Django項目

部署過程:https://www.cnblogs.com/erhangboke/p/11678486.html

按照教程都部署好了,但是請求時發現報504超時錯誤

問題定位:

由於是走了nginx代理,所以可能和nginx配置相關,於是找解決方法

解決過程:

1.查閱資料后,覺得可能是nginx代理超時,將nginx.conf或者vhost中的配置文件中加入設置的代理時長,結果還是沒起作用:
proxy_connect_timeout 300s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
send_timeout 300s;

2.最后設置了fastcgi的超時配置,重啟nginx.
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
發現還不行

3、查看了django_nginx.conf

server {
listen 8000;
server_name 0.0.0.0;
access_log /var/log/nginx/mysite_access.log;
error_log /var/log/nginx/mysite_error.log;
charset utf-8;
keepalive_timeout 65;
client_max_body_size 75M;
root /data/jenkins/mysite;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9001;
uwsgi_read_timeout 2; #發現這個值比較小
}
location /static/ {
expires 30d;
autoindex on;
add_header Cache-Control private;
alias /data/jenkins/mysite/static/;
}

location /media/ {
expires 30d;
autoindex on;
add_header Cache-Control private;
alias /data/jenkins/mysite/media/;
}
}

將此值修改為300后,再次請求,OK了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM