在centos上无法访问gunicorn api

eoigrqb6  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(144)

问题:我无法访问我的 gunicorn api从我的本地计算机。
我有一个 Python 应用程序,使用 gunicornCentOS 服务器(否) nginx 或者类似的东西)。它正在发挥作用:

[xxx@xxx xxx]$ poetry run gunicorn api.main:app -b 0.0.0.0:5000 -w 4 -k uvicorn.workers.UvicornWorker
Using python3 (3.9.5)
[2021-07-08 11:13:06 +0200] [16213] [INFO] Starting gunicorn 20.1.0
[2021-07-08 11:13:06 +0200] [16213] [INFO] Listening at: http://0.0.0.0:5000 (16213)
[2021-07-08 11:13:06 +0200] [16213] [INFO] Using worker: uvicorn.workers.UvicornWorker
[2021-07-08 11:13:06 +0200] [16224] [INFO] Booting worker with pid: 16224
[2021-07-08 11:13:06 +0200] [16232] [INFO] Booting worker with pid: 16232
[2021-07-08 11:13:06 +0200] [16233] [INFO] Booting worker with pid: 16233
[2021-07-08 11:13:06 +0200] [16234] [INFO] Booting worker with pid: 16234
[2021-07-08 11:13:09 +0200] [16224] [INFO] Started server process [16224]
[2021-07-08 11:13:09 +0200] [16224] [INFO] Waiting for application startup.
[2021-07-08 11:13:09 +0200] [16224] [INFO] Application startup complete.
[2021-07-08 11:13:09 +0200] [16232] [INFO] Started server process [16232]
[2021-07-08 11:13:09 +0200] [16232] [INFO] Waiting for application startup.
[2021-07-08 11:13:09 +0200] [16232] [INFO] Application startup complete.
[2021-07-08 11:13:09 +0200] [16234] [INFO] Started server process [16234]
[2021-07-08 11:13:09 +0200] [16234] [INFO] Waiting for application startup.
[2021-07-08 11:13:09 +0200] [16234] [INFO] Application startup complete.
[2021-07-08 11:13:09 +0200] [16233] [INFO] Started server process [16233]
[2021-07-08 11:13:09 +0200] [16233] [INFO] Waiting for application startup.
[2021-07-08 11:13:09 +0200] [16233] [INFO] Application startup complete.

我有一个用于测试的简单端点,当我从服务器本身调用它时,它正在工作,通过调用 localhost 和服务器地址:

[xxx@xxx xxx]$ curl localhost:5000/get_test
"Thanks for calling!"
[xxx@xxx xxx]$ curl myserveraddress.com:5000/get_test
"Thanks for calling!"

我可以从windows计算机ping服务器,一切正常:

C:\>ping myserveraddress.com

Pinging myserveraddress.com [xx.xx.xx.xx] with 32 bytes of data:
Reply from xx.xx.xx.xx: bytes=32 time=51ms TTL=55
Reply from xx.xx.xx.xx: bytes=32 time=51ms TTL=55
Reply from xx.xx.xx.xx: bytes=32 time=51ms TTL=55
Reply from xx.xx.xx.xx: bytes=32 time=51ms TTL=55

但我无法从我的计算机访问此终结点(我收到超时):

C:\>curl myserveraddress.com:5000/get_test
curl: (7) Failed to connect to myserveraddress.com port 5000: Timed out
``` `firewalld` 规则似乎不是问题,因为它们都是公开的:

[xxx@xxx xxx]$ sudo firewall-cmd --get-default-zone
public
[xxx@xxx xxx]$ sudo firewall-cmd --get-active-zones
public
interfaces: ens192

但我特别在规则中添加了端口5000:

[xxx@xxx xxx]$ sudo firewall-cmd --add-port=5000/tcp --permanent
success
[xxx@xxx xxx]$ sudo firewall-cmd --reload
success
[xxx@xxx xxx]$ sudo firewall-cmd --query-port=5000/tcp
yes

每次手术后,我都会重新开始 `gunicorn` 服务器。
我也查过了 `iptables` (但据我所知 `firewalld` 使用 `iptables` 下面),但整个输出由所有和任何地方组成,例如:

Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere

我还可以做些什么来允许流量进入我的web服务器?或者只是调试,问题是什么?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题