gpt4 book ai didi

python - 尝试在 Nginx 服务器 Ubuntu 21.10 实例上部署我的 flask 应用程序时,我得到了经典的 "Permission denied while connecting to upstream"

转载 作者:行者123 更新时间:2023-12-04 18:58:50 25 4
gpt4 key购买 nike

我知道这个问题已经被问过一百万次了,而且我几乎尝试了所有的“解决方案”都无济于事。我在想我的问题可能是独一无二的。
uwsgi.ini:

module = wsgi:app
master = true
processes = 5
socket = elekto.sock
chmod-socket = 666
vacuum = true
die-on-term = true
logto = /home/richardgrecoson/elekto/elekto.log
/etc/nginx/sites-enabled/elekto :
server {
listen 80;
server_name my_ip;
location / {
include uwsgi_params;
uwsgi_pass unix:/home/richardgrecoson/elekto/elekto.sock;
}
}
/etc/systemd/system/elekto.service
[Unit]
Description=uWSGI instance to serve myproject
After=network.target

[Service]
User=richardgrecoson
Group=www-data
WorkingDirectory=/home/richardgrecoson/elekto
Environment="PATH=/home/richardgrecoson/elekto/.venv/bin"
ExecStart=/home/richardgrecoson/elekto/.venv/bin/uwsgi --ini uwsgi.ini

[Install]
WantedBy=multi-user.target

最佳答案

您的 NGINX 不允许对套接字文件进行 r/w/x。让我们尝试一些事情。
将socket的权限改为0777并通过 ls /home/richardgrecoson/elekto/elekto.sock 进行检查
一般来说,允许 NGINX 的运行用户 r/w/x 套接字是很重要的。 nginx 的运行用户是“正常”nginx .输入 ps -elf |grep nginx 进行检查
如果是 NGINX,我会将套接字的权限改回 660并将用户和组更改为 nginx .
有了这个,nginx 用户将可以访问套接字。
如果您想为套接字使用与 nginx 不同的运行用户,请创建一个新用户并将其添加到 nginx 组usermod -a -G nginx yourusername .这将适用于 660也是。

关于python - 尝试在 Nginx 服务器 Ubuntu 21.10 实例上部署我的 flask 应用程序时,我得到了经典的 "Permission denied while connecting to upstream",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71090243/

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