繁体   English   中英

无法使用gunicorn运行nginx,连接到上游时出现权限被拒绝的错误

[英]Could not run nginx with gunicorn, getting permission denied error while connecting to upstream

我已经用Nginx和Gunicorn托管了django。 我收到以下错误。

# 1 connect() to 127.0.0.1:8001 failed (13: Permission denied) while connecting to upstream, client: 106.77.61.123, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:8001/favicon.ico", host: "<domainname>

[相同的配置正在我的本地centos机器上工作]

但是在VPS托管环境(vps)上:

我正在使用具有用户名“ ftpuser1”的centos-7(nginx.conf中的用户名是“ ftpuser1”)。

我正在使用用户“ ftpuser1”运行nginx

/ var / cache / nginx的所有者递归具有777权限的“ ftpuser1”

源代码路径的所有者也是具有777权限的“ ftpuser1”

这是我的/etc/nginx/conf.d/default.config配置文件的内容:

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location / {
        root   /home/ftpuser1/donation/templates;
        index  home.html;
        proxy_pass http://127.0.0.1:8001;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #} }

有人可以帮我吗?

此错误消息表示,如果您在Linux环境中,则您对提供服务“ favicon.ico”的根文件夹没有读写权限;

尝试以下命令: sudo chmod 775 /<foldername>

sudo开始时不要忘记sudo

然后,在您应用权限之后,尝试重新启动* nginx服务器

  1. 在配置末尾固定右括号“}”(不是问题)
  2. 尝试输入“ user ftpuser1;” 在“服务器{..}”之前的配置顶部

暂无
暂无

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

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