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

How to check Nginx is work? (Python: Flask+Gunicorn+Nginx)

项目路径为“/home/API_AIcustomerservice”

API url 是 "XXX.XXX.XXX.XXX:5061"

API 的 python 文件名为 "start_honsecaistk.py"

我非常确定 Gunicorn 和 Flask 可以正常工作。 (我可以成功访问 API url)

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

[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,不是在你想用 nginx 代理的本地主机上,而是在你拥有的外部 ip 上。所以你可以改变那个或代理通行证 url.

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