无法使用gunicorn运行nginx,在连接到上游时获得权限被拒绝错误

时间:2014-09-06 12:39:46

标签: django nginx centos

我用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)上:

我使用的是centos-7,用户名为#34; ftpuser1&#34; (nginx.conf中的用户名是&#34; ftpuser1&#34;)。

我正在使用用户&#34; ftpuser1&#34;

运行nginx / var / nginx的所有者是&#34; ftpuser1&#34;以递归方式获得777权限

源代码路径的所有者也是&#34; ftpuser1&#34;以递归方式获得777权限

这是我的/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;
    #} }

有人可以帮助我吗?

2 个答案:

答案 0 :(得分:0)

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

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

在你的命令开始时不要忘记sudo

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

答案 1 :(得分:0)

  1. 修复配置末尾的结束括号“}”(不是问题)
  2. 尝试输入“user ftpuser1;”在“server {..}”
  3. 之前的配置顶部