当我连接到我的网站时,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
答案 0 :(得分:0)
您使用了错误的设置来告诉uwsgi使用HTTP端口。您需要http-socket
而不是socket
。
答案 1 :(得分:0)
上游有多个原因可能返回无效甚至不返回任何响应
验证上游uwsgi是否实际上在centos实例中本地运行并且可以处理传入请求
为此进行验证,以在uwsgi.ini中以 Gson gson = new GsonBuilder()
.setDateFormat(Constants.TimeStamp + System.currentTimeMillis() + Constants.Slash)
.create();
Gson gson = new GsonBuilder()
.registerTypeAdapter(Id.class, new IdTypeAdapter())
.enableComplexMapKeySerialization()
.serializeNulls()
.setDateFormat(Constants.TimeStamp + System.currentTimeMillis() + Constants.Slash)
.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
.setPrettyPrinting()
.setVersion(1.0)
.create();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(API.BASE_URL)
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
的身份运行它,然后运行http-socket = :8000
如果uwsgi在本地主机上运行良好,则将配置更改回uwsgi --ini uwsgi.ini
在centos 7.x上,SELinux软件包已启用并以强制模式运行。因此,它不允许nginx写入/连接到套接字。
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
getsebool -a | grep httpd