flask-wsgi-nginx SSL不起作用(61:连接被拒绝)

时间:2019-03-14 17:28:26

标签: ssl nginx flask https wsgi

确保这是一个愚蠢的问题,但这使我发疯。

我有一个使用python3 flask开发的网络应用,正在测试通过HTTPS运行它。

我配置了NGINX和WSGI,并且能够以HTTP模式在localhost上运行它。

如果我尝试更改应用程序NGINX文件并使其在HTTPS中运行,则它将不起作用。

错误日志不断告诉我:

2019/03/14 13:24:07 [error] 13176#0: *272 kevent() reported that connect() failed (61: Connection refused) while connecting to upstream, client: 127.0.0.1, server: genetonic, request: "GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:3031", host: "localhost"

我的NGINX应用程序文件:

server {

listen 443 default_server ssl;
server_name genetonic;

ssl_certificate /Users/cccnrc/Documents/columbia/mycert/cert.pem;
ssl_certificate_key /Users/cccnrc/Documents/columbia/mycert/key.pem;

set $home /Users/cccnrc/Documents/columbia/github/geneTonic;
access_log /Users/cccnrc/Documents/columbia/github/geneTonic/nginx/access.log;
error_log /Users/cccnrc/Documents/columbia/github/geneTonic/nginx/error.log;

rewrite ^/(.*)/favicon.ico$ /static/images/favicon.ico last;

location / {
    uwsgi_pass localhost:3031;
    include uwsgi_params;
    uwsgi_param USWGI_CHDIR $home/genetonic;
    uwsgi_param USWGI_INI genetonic;
    root $home;
}
location /static/ {
    root $home;
    autoindex on;
    error_page 404 = "404";
}
}

我的WSGI配置文件在app文件夹中:

[uwsgi]
module = wsgi

master = true
processes = 2

chdir = /Users/cccnrc/Documents/columbia/github/geneTonic/

url_scheme = https

socket = /Users/cccnrc/Documents/columbia/github/geneTonic/genetonic.sock
chmod-socket = 660
vacuum = true

die-on-term = true

正如我说的,如果我通过HTTP连接,它将起作用:

curl http://localhost

<html>

<head>
  <title>&#x2372;sylum</title>
</head>


<body>

    <div>Hello World</div>

    <hr>





<div>Index Page</div>


</body>

</html>

但是如果我通过HTTPS连接,则不会:

curl -k https://localhost:443

<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.15.9</center>
</body>
</html>

有人知道吗?

非常感谢!

PS:如果可以帮助我开发MAC OS X

0 个答案:

没有答案