nginx - 我无法提供来自 nginx 的 gunicorn 请求
问题描述
我有一个在 nginx 服务器上运行的反应网络应用程序。服务器在端口 80 上运行。
它的conf是这样的:
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 提供静态文件,当在反应端发出 fetch 请求时,它将被传递到 127.0.0.1:5000 上的 gunicorn 和 flask
当我将位置设置为位置 /insert_email (我的反应提取)时,我可以加载网站,但我从未在我的 Gunicorn 服务器上收到电子邮件插入请求
解决方案
这是一个示例 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 上的流量。
推荐阅读
- php - 如何检查给定日期的预订时段
- mysql - 在mysql中插入X(从Z中选择Y)是否有更快的替代方法?
- iot - 如何通过我的网站控制我的 Arduino ESP8266 wifi 模块(来自 anywwre)
- sql - SQL Sum count of product by Member 和产品 YTD 的产品计数
- html - 元素内不同数量的 div 列的水平滚动
- postgresql - 我应该使用复合主键来加快 PostgreSQL 中基于时间戳的选择吗?
- docker - 使用 docker 命令将 Jager-agent 配置为 FluentD 等 UDP 服务器
- r - R:以第一个索引为起点的滚动标准偏差并忽略 NA
- laravel - 在查询中过滤(搜索引擎)的最佳方法
- c++ - 在 Sql server time 数据类型中保存 PC 时间并在 QT 中读回