繁体   English   中英

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

[英]Nginx, django, gunicorn, ubuntu 14.04 (13: Permission denied) while connecting to upstream

我正在使用nginxgunicorn在我的django项目中工作,正如它在这里所说的:

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

我的网站在本地工作,但是当我启动nginxgunicorn服务器时,我有

502 错误网关错误。

操作系统是UBUNTU 14.04

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

这是我的“error.log”:

2016/04/20 20:15:10 [暴击] 10119#0:*1 连接()到
unix:/root/myproject/myproject.sock 连接到上游时失败(13:权限被拒绝),客户端: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

description "Gunicorn application server handling myproject" start on runlevel [2345] stop on runlevel [!2345] respawn 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

请在此处使用其他用户。

根据您的 nginx 错误日志,我认为您还有其他一些使用端口 80 的进程。

您必须弄清楚该进程是什么,并在不需要时将其杀死。 或者使用其他端口。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM