我正在尝试托管一个演示烧瓶应用程序,该应用程序在运行时返回"hi there"。我已经成功地用http和https单独使用Uwsgi来托管应用程序。当我尝试使用 https config 在本地主机上访问我的应用程序时,我得到
502. Bad Gatewat
nginx/1.4.6 (Ubuntu)
这是我的部署.ini(UWSGI 配置文件)
[uwsgi]
shared-socket = 127.0.0.1:8443
master = true
processes = 5
daemonize = /path/to/my/mylog.log
wsgi-file=/path/to/my/demo.py
callable=app
https= =0,ca.crt,ca.key,HIGH
我也尝试过使用 unix 套接字并更改其权限 shared-socket=/path/to/my.soc chmod-socket=664
使用第一个配置,我可以启动应用程序,但只能使用 UWSGI,我想让它通过 nginx 工作。
这是我的 nginx 配置
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
error_log /path/to/nginx_err.log;
listen 443 ssl default_server;
server_name localhost;
ssl_certificate path/to/ca.crt;
ssl_certificate_key path/to/ca.key;
location / {
uwsgi_pass 127.0.0.1:8443;
#uwsgi_pass unix:///path/to/my.soc;
include uwsgi_params;
}
}
它非常适合https,但我不知道当我尝试提供https配置时发生了什么
我的日志文件/var/log/nginx/error.log
2016/03/22 15:58:07 [error] 12926#0: *2 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /user HTTP/1.1", upstream: "uwsgi://127.0.0.1:8443", host: "127.0.0.1"
我已经花了大约 8 个小时来解决这个问题,但无法.任何帮助都非常感谢
当 uWSGI 前面有 nginx 时,你不应该在 uWSGI 中配置任何与 https 相关的内容。
uWSGI 中的 https 设置仅用于直接连接到 uWSGI 服务器。这将激活内置的http/https服务器,因此不再需要nginx。更多关于这一点,uWSGI将不再在指定的端口上使用uwsgi协议,并且该协议在当前配置中被nginx所期望。
将您的uWSGI设置更改为:
[uwsgi]
socket = 127.0.0.1:8443
master = true
processes = 5
daemonize = /path/to/my/mylog.log
wsgi-file=/path/to/my/demo.py
callable=app
它会正常工作。不要担心nginx或uWSGI之间的安全连接。如果是本地连接(环回或安全的本地网络),则不会有问题。