微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

python – 连接到上游时的Nginx,django,gunicorn,ubuntu 14.04(13:权限被拒绝)

我正在使用Nginx和gunicorn在我的django项目上工作,正如它在这里所说:

https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-14-04

我的网站在本地工作,但是当我启动Nginx和gunicorn服务器时

502 Bad Gateway error.

操作系统是UBUNTU 14.04

我正在尝试让我的项目工作,并以root身份重新安装所有内容(我知道它很糟糕) – 同样的错误.

这是我的“error.log”:

2016/04/20 20:15:10 [crit] 10119#0: *1 connect() to
unix:/root/myproject/myproject.sock Failed (13: Permission denied)
while connecting to upstream, client: 46.164.23

当我运行命令“Nginx”时:

  Nginx: [emerg] bind() to 0.0.0.0:80 Failed (98: Address already in use)
  Nginx: [emerg] bind() to 0.0.0.0:80 Failed (98: Address already in use)
  Nginx: [emerg] bind() to 0.0.0.0:80 Failed (98: Address already in use)
  Nginx: [emerg] bind() to 0.0.0.0:80 Failed (98: Address already in use)
  Nginx: [emerg] bind() to 0.0.0.0:80 Failed (98: Address already in use)
  Nginx: [emerg] still Could not bind()

我的gunicorn.conf

描述“处理myproject的Gunicorn应用服务器”
从运行级别开始[2345]
停在运行级别[!2345]
重生
setuid root
setgid www-data
chdir / root / myproject
exec myprojectenv / bin / gunicorn –workers 3 –bind unix:/root/myproject/myproject.sock myproject.wsgi:application

多数民众赞成我的“/ etc / Nginx / sites-available / myproject”

server {
listen 80;
server_name         www.mysite.ru;

error_log /Nginx_error.log;

location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
    root /root/myproject;
}

location / {
    include proxy_params;
    proxy_pass http://unix:/root/myproject/myproject.sock;
}

}

我非常感谢你的帮助!

解决方法:

proxy_pass http://unix:/root/myproject/myproject.sock;

套接字位于超级用户的主文件夹中.对于包括你的Nginx用户在内的所有其他用户来说,这几乎是无法访问的.请将插座更多地连接到其他位置. / var / log / gunicorn /是个好地方.

我也看到你以root身份运行gunicorn吗?不建议.

setuid root

在这里使用其他用户.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐