gpt4 book ai didi

python - Bottle + nginx : connect() failed (111: Connection refused) while connecting to upstream

转载 作者:行者123 更新时间:2023-12-04 19:41:54 32 4
gpt4 key购买 nike

我在我的 nginx 错误日志中收到大量以下错误:

connect() failed (111: Connection refused) while connecting to upstream

我的应用程序在其他方面工作正常,如果我尝试从日志中访问 url,它们在浏览器中都显示正常,但我仍然想追踪这些错误的来源。

我尝试在我的 nginx 配置中启用保持事件,但它没有改变任何东西。
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Connection "";
}


我的服务器运行 CentOS 7.6、Python 2.7.5、bottle 0.13-dev 和 nginx 1.12.2。

这是一个使用 gevent 服务器的瓶子网络应用程序:

bottle.run(app=myapp, host='0.0.0.0', port=8080, debug=False, quiet=True, reloader=False, server='gevent')

这是我的 nginx 配置:
server {
listen 80;
server_name *****;
proxy_set_header X-Forwarded-For $remote_addr;

root /usr/local/*****;
client_max_body_size 128M;

location /static {
}

location /protected {
internal;
}

location / {
proxy_pass http://localhost:8080;
}

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/*****/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/*****/privkey.pem; # managed by Certbot
# include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot

if ($scheme != "https") {
return 301 https://$host$request_uri;
} # managed by Certbot
}

难道仅仅是 gevent 和 bottle 没有足够快地处理请求并给出临时连接拒绝错误吗?我应该尝试使用像 uWSGI 这样的另一台服务器还是使用一些 nginx 代理优化?

最佳答案

我将瓶子与 nginx 一起使用并且工作正常,我使用 gunicorn wsgi 服务器处理负载,它工作得非常好,我尝试只使用

python3 app.py

工作正常我建议您使用此代码来设置瓶子服务器
import bottle
from bottle import run

if __name__ == '__main__':
run(host='localhost', port=8080)
application = bottle.default_app()

我认为最好用/像这样完成代理通行证
location / {
proxy_pass http://localhost:8080/;
}

关于python - Bottle + nginx : connect() failed (111: Connection refused) while connecting to upstream,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57184315/

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