Centos7,当我连接到我的网站时,显示502 Bad Gateway, 我用命令测试我的网站 uwsgi --ini systemctl启动nginx 我无法弄清楚发生了什么,请帮助我!
这是nginx.conf
upstream django {
server 127.0.0.1:8000;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com;
charset utf-8;
include /etc/nginx/default.d/*.conf;
location / {
include uwsgi_params;
uwsgi_pass django;
}
location /static/ {
alias /usr/local/etc/dmp/static/;
}
}
和uwsgi设置
[uwsgi]
chdir = /usr/local/etc/dmp
module = DMP_python.wsgi
plugins = python3
socket = :8000
chmod-socket = 666
master = true
processes = 2
vacuum = true
您使用错误的设置告诉uwsgi使用HTTP端口。你需要http-socket
而不是socket
。
可能有多种原因导致上游无效或甚至不返回任何响应
http-socket = :8000
然后运行uwsgi --ini uwsgi.ini
如果uwsgi在localhost上正常运行,那么将配置更改回socket = :8000
grep nginx /var/log/audit/audit.log | audit2allow -m nginx
由grep nginx /var/log/audit/audit.log | audit2allow -M nginx
这样做
最后semodule -i nginx.pp
现在应该解决连接套接字问题的权限
验证nginx是否可以与上游建立网络连接。检查nginx error.log或getsebool -a | grep httpd
允许它运行setsebool httpd_can_network_connect on -P