gpt4 book ai didi

python - nginx uwsgi 502 错误网关

转载 作者:太空宇宙 更新时间:2023-11-03 16:33:05 31 4
gpt4 key购买 nike

我的 nginx 和 uwsgi 配置完美适用于前一个或两个请求。然后 nginx 显示 502 Bad Gateway。当我重新启动 uwsgi 服务时,同样的事情再次发生。我使用的是 Ubuntu 16.04。这是我的所有配置和错误日志:

nginx 配置:

upstream book {
server unix:///tmp/book.sock;
}

server {
listen 80;
server_name example.com;
return 301 https://$host$request_uri;
}

server {
listen 443 ssl http2;
server_name example.com;
......
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;

charset utf-8;

client_max_body_size 100M;

access_log /var/log/nginx/example.com_access.log;
error_log /var/log/nginx/example.com_error.log;

location /media {
alias /home/prism/prod/example.com/media;
}

location /static {
alias /home/prism/prod/example.com/static;
}

location / {
uwsgi_pass book;
include /etc/nginx/uwsgi_params;
}

}

/var/log/nginx/example.com_error.log

2016/05/25 17:44:26 [error] 5230#5230: *214 connect() to unix:///tmp/book.sock failed (111: Connection refused) while connecting to upstream, client: 27.*.*.*, server: example.com, request: "GET / HTTP/2.0", upstream: "uwsgi://unix:///tmp/book.sock:", host: "example.com"

hiren.ini

[uwsgi]
chdir=/home/prism/prod/example.com
home = /home/prism/prod/example.com/.env
module=hiren.wsgi
master=True
process = 5
pidfile=/tmp/book.pid
socket= /tmp/book.sock
vacuum=True
max-requests=5000
daemonize=/home/prism/prod/example.com/hiren.log
uid = www-data
gid = www-data
die-on-term = true

和服务文件:

[Unit]
Description=uWSGI instance to serve example.com

[Service]
User=prism
ExecStart=/bin/bash -c 'cd /home/prism/prod/example.com; source .env/bin/activate; uwsgi --ini hiren.ini'

[Install]
WantedBy=multi-user.target

最佳答案

通过调整systemd脚本解决了问题

[Unit]
Description=uWSGI instance to serve example.com

[Service]
ExecStart=/bin/bash -c 'su prism; cd /home/prism/prod/example.com; source .env/bin/activate; uwsgi --ini hiren.ini'

[Install]
WantedBy=multi-user.target

关于python - nginx uwsgi 502 错误网关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37436609/

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