gpt4 book ai didi

python - 如何检查 Nginx 是否工作? (Python : Flask+Gunicorn+Nginx)

转载 作者:太空宇宙 更新时间:2023-11-03 21:30:35 24 4
gpt4 key购买 nike

项目路径为“/home/API_AIcustomerservice”

API 网址为“XXX.XXX.XXX.XXX:5061”

名为“start_honsecaistk.py”的API的python文件

我非常确定 Gunicorn 和 Flask 是有效的。 (我可以成功访问API url)

我通过命令“gunicorn -c/home/API_AIcustomerservice/gconfig.py start_honsecaistk:app”和 gconfig.py 运行 Gunicorn

[gconfig.py]

from gevent import monkey
monkey.patch_all()
import multiprocessing
debug = True
loglevel = 'debug'
bind = 'XXX.XXX.XXX.XXX:5061'
pidfile = 'log/gunicorn.pid'
logfile = 'log/debug.log'
workers = multiprocessing.cpu_count() * 2 + 1
worker_class = 'gevent'

关于 Nginx我编辑了文件:vim/etc/nginx/sites-available/default

server {
listen 80;
root /home/API_AIcustomerservice;
server_name XXX.XXX.XXX.XXX;
location / {
proxy_set_header x-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://localhost:5061/;
}
location ~ ^\/static\/.*$ {
root /home/API_AIcustomerservice;
}
}

编辑后,我运行sudo service nginx restart

然后。如何检查 Nginx 是否可以使用 API url?我问这个问题是因为我运行 sudo service nginx stop并且API url仍然可以访问。我看不到 Nginx 的影响。

感谢您抽出时间。我发自内心地感谢你们。

最佳答案

你与gunicorn的绑定(bind)不是在你想要用nginx代理的本地主机上,而是在你拥有的外部IP上。因此您可以更改该地址或代理传递 url。

当您停止 nginx 时,它不会终止您的应用程序,并且如果它正在运行,您仍然可以访问它。要检查 nginx 代理是否工作正常,您可以 curl url,例如在你的情况下,它是 curl http://XXX.XXX.XXX.XXX

关于python - 如何检查 Nginx 是否工作? (Python : Flask+Gunicorn+Nginx),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53552725/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com