[英]Django 502 bad gateway with Nginx and Uwsgi
部署后幾個小時我可以在前面正常打開我的網絡,但后來發生了 502 壞網關,它是如此有線,我的網絡使用 Django、Nginx 和 Uwsgi,我在谷歌上做了很多研究,但一無所獲
這是我的配置:
1.Nginx配置
# mysite_nginx.conf
upstream django {
server 127.0.0.1:8004; # for a web port socket (we'll use this first)
}
server {
listen 80;
server_name www.example.com # substitute your machine's IP address or FQDN
charset utf-8;
client_max_body_size 75M; # adjust to taste
location /media {
alias /home/blender_font_project/django_file/Blender_website/media;
}
location /static {
alias /home/blender_font_project/django_file/Blender_website/static;
}
location / {
uwsgi_pass 127.0.0.1:8003;
include /etc/nginx/uwsgi_params;
}
}
2.uwsgi配置
# mysite_uwsgi.ini file
[uwsgi]
chdir = /home/blender_font_project/django_file/Blender_website
module = djangoTest5.wsgi
master = true
processes = 10
socket = :8003
vacuum = true
harakiri=60
daemonize=/home/blender_font_project/uwsgi_file/real3dfont_logfile
3.這是我的 Nginx 錯誤日志
231 connect() failed (111: Connection refused) while connecting to upstream
順便說一句,我已將 Django 設置為 DEBUG Ture,我可以通過www.example.com/static/example.jpg
訪問我的資源,但網頁顯示 502
我真的不知道為什么,如果你提供任何幫助,謝謝!
(......經過百萬年的奮斗和奮斗,在評論中一位名叫@Atul Mishra 的超級英雄的啟發下,我終於弄明白了......)
這是 Django 本身的問題,我忘記在 View 中下載 mysql 模塊,如果是 django 問題,我會期望 Django 錯誤 html,但沒有,所以我錯誤地將其歸因於 Nginx 或 Uwsgi
但有線的事情是Django應該報告錯誤,但沒有! 真是個不負責任的家伙!!
所以,1.記得添加Django錯誤日志功能,它可以救你一命,並且
2.即使彗星撞擊地球,在Nginx進入舞台之前用runserver測試Django!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.