带有uwsgi和flask的nginx仅显示对https连接的错误请求

带有uwsgi和flask的nginx仅显示对https连接的错误请求,nginx,flask,uwsgi,Nginx,Flask,Uwsgi,我正在尝试主持一个演示烧瓶应用程序,它在运行时返回“hi there”。我已经成功地使用此配置单独使用Uwsgi通过http和https托管应用程序。 当我尝试使用https配置在本地主机上访问我的应用程序时,我得到 502. Bad Gatewat nginx/1.4.6 (Ubuntu) 下面是my deployment.ini(uwsgi配置文件) 我也尝试过使用unix套接字,并更改了它的权限 共享套接字=/path/to/my.soc chmod插座=664 使用第一种配置,我可以

我正在尝试主持一个演示烧瓶应用程序,它在运行时返回“hi there”。我已经成功地使用此配置单独使用Uwsgi通过http和https托管应用程序。 当我尝试使用https配置在本地主机上访问我的应用程序时,我得到

502. Bad Gatewat 
nginx/1.4.6 (Ubuntu)
下面是my deployment.ini(uwsgi配置文件)

我也尝试过使用unix套接字,并更改了它的权限 共享套接字=/path/to/my.soc chmod插座=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个小时来解决这个问题,但无法解决。
非常感谢您的帮助

如果前面有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之间的连接是否安全。如果是本地连接(环回或安全本地网络),则不会成为问题

[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