我无法提供来自nginx的gunicorn请求

问题描述 投票:0回答:1

我有一个在nginx服务器上运行的反应Web应用程序。服务器在端口80上运行。

它的内容是这样的:

location / { 
    proxy_pass http://127.0.0.1:5000;
    proxy_connect_timeout 75s;
    proxy_read_timeout 300s;
    try_files $uri $uri/ =404;

Gunicorn绑定到我的烧瓶应用程序并运行在127.0.0.1:5000。当我这样做时,我看不到我的网站。它说

This site can’t be reached 127.0.0.1 refused to connect.

理想情况下,Nginx将通过端口80提供静态文件,当在反应端进行获取请求时,它将被传递到gunicorn和flask 127.0.0.1:5000

当我将位置设置为location / insert_email(我的反应获取)时,我可以加载网站,但我从未在我的Gunicorn服务器上收到电子邮件插入请求

nginx gunicorn
1个回答
1
投票

这是一个示例NGINX配置,我知道它可以作为Gunicorn的反向代理。

#Config Contents
server {
    listen       80;
    server_name  site.your.domain;
    # Or use the following if you do not have a domain
    #server_name 123.123.123.123;

    location / {
        proxy_pass http://127.0.0.1:5000;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Scheme $scheme;
    }
}

Gunicorn Run字符串看起来像

gunicorn --bind localhost:5000 flask_app:app

作为完整性检查,您可以检查哪些进程正在侦听使用哪些端口

lsof -i -P -n | grep LISTEN

确保您的服务器至少从您的IP地址允许端口80上的流量。

© www.soinside.com 2019 - 2024. All rights reserved.