![](/img/trans.png)
[英]Domain Name not working with Nginx (Python: Flask+Gunicorn+Nginx)
[英]How to check Nginx is work? (Python: Flask+Gunicorn+Nginx)
项目路径为“ / home / API_AIcustomerservice”
API网址为“ XXX.XXX.XXX.XXX:5061”
API的python文件名为“ start_honsecaistk.py”
我非常确定Gunicorn和Flask可以使用。 (我可以成功访问API网址)
我使用gunicorn -c /home/API_AIcustomerservice/gconfig.py start_honsecaistk:app
通过命令“ gunicorn -c /home/API_AIcustomerservice/gconfig.py start_honsecaistk:app
”运行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网址? 我问这个问题是因为我运行sudo service nginx stop
并且仍然可以访问API url。 我看不到Nginx的影响。
感谢您抽出宝贵的时间。 我衷心感谢你。
您在不希望使用nginx代理的localhost上与gunicorn绑定,但是在外部ip上具有。 因此,您可以更改该URL或代理传递URL。
当您停止nginx时,它不会终止您的应用程序,并且如果它正在运行,您仍然可以访问它。 要检查nginx代理是否工作正常,您可以卷曲URL,例如, curl http://XXX.XXX.XXX.XXX
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.