需要有关502 Bad Gateway ngnix / 1.10.3的帮助
我已经使用Nginx / Gunicorn配置了Django应用程序。在我对代码进行一些更改并重新加载服务器之前,它运行良好。
仅供参考:我的settings.py具有ALLOWED_HOSTS = ['*']
错误日志:
2018/06/27 08:36:38 [crit] 7444#7444: *35 connect() to unix://home/ubuntu/www/MySite/MySite.sock failed (13: Permission denied) while connecting to upstream, client: 106.51.16.0, server: 18.191.255.247, request: "GET /report/ HTTP/1.1", upstream: "http://unix://home/ubuntu/www/MySite/MySite.sock:/report/", host: "18.191.255.247"
2018/06/27 08:36:40 [crit] 7444#7444: *35 connect() to unix://home/ubuntu/www/MySite/MySite.sock failed (13: Permission denied) while connecting to upstream, client: 106.51.16.0, server: 18.191.255.247, request: "GET /report/ HTTP/1.1", upstream: "http://unix://home/ubuntu/www/MySite/MySite.sock:/report/", host: "18.191.255.247"
2018/06/27 08:36:41 [crit] 7444#7444: *35 connect() to unix://home/ubuntu/www/MySite/MySite.sock failed (13: Permission denied) while connecting to upstream, client: 106.51.16.0, server: 18.191.255.247, request: "GET /report/ HTTP/1.1", upstream: "http://unix://home/ubuntu/www/MySite/MySite.sock:/report/", host: "18.191.255.247"
2018/06/27 08:39:06 [crit] 7444#7444: *41 connect() to unix://home/ubuntu/www/MySite/MySite.sock failed (13: Permission denied) while connecting to upstream, client: 106.51.16.0, server: 18.191.255.247, request: "GET /report/ HTTP/1.1", upstream: "http://unix://home/ubuntu/www/MySite/MySite.sock:/report/", host: "18.191.255.247"
更新1:
这是我的Nginx配置。这有什么问题吗?
/ etc / nginx / sites-available / MySite
server {
listen 80;
server_name 18.191.255.247;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/ubuntu/www/MySite;
}
location / {
include proxy_params;
proxy_pass http://unix://home/ubuntu/www/MySite/MySite.sock;
}
}
如何验证nginx守护程序对项目文件夹(// unix:// home / ubuntu / www / MySite)的权限
答案 0 :(得分:1)
尝试手动将代理传递URL设置为端口gunicorn正在服务器上运行项目,例如:
location / {
proxy_pass http://localhost:8000;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 500;
proxy_read_timeout 600;
}
答案 1 :(得分:0)
是的,存在配置问题
location / {
include proxy_params;
proxy_pass http://unix:/home/ubuntu/www/MySite/MySite.sock;
}
/etc/init.d/nginx restart
使用以下命令检查套接字文件的权限
ls -l /home/ubuntu/www/MySite/MySite.sock