【问题标题】:nginx invalid number of arguments in "proxy_pass" directivenginx“proxy_pass”指令中的参数数量无效
【发布时间】:2019-01-06 04:10:06
【问题描述】:
nginx: [emerg] invalid number of arguments in "proxy_pass" directive in /etc/nginx/sites-enabled/django_direct:12

我的 nginx 配置文件:

server {
    listen 80;
    server_name 94.154.13.214;

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

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

我该怎么办? 更新: 我已经更改了这样的文件:

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

但没有帮助,我已经重新启动了 nginx,现在 我现在收到 502 Bad Gateway 错误。

【问题讨论】:

  • unix: 在这里做什么?这不应该是一条路吗?
  • 你在 unix: 和路径的其余部分之间有一个额外的剃须。
  • @DanielRoseman 查看更新
  • @user2950593:你得到完全相同的错误?
  • @user2950593:你重启了nginx服务器了吗?

标签: django nginx


【解决方案1】:

你的论点是错误的。 它需要一个 URL:

设置代理服务器的协议和地址,以及一个位置应映射到的可选 URI。作为协议,可以指定“http”或“https”。地址可以指定为域名或IP地址,以及可选的端口:

proxy_pass http://localhost:8000/uri/;

或作为在单词“unix”之后指定并用冒号括起来的 UNIX 域套接字路径:

proxy_pass http://unix:/tmp/backend.socket:/uri/;

查看文档:http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass

【讨论】:

    【解决方案2】:

    nginx 看到两个参数:unix/root/django_redirect/...。但是,我有一个想法,即您要指定一个 UNIX 域套接字路径。你可以这样做:

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

    documentation 中所述。

    【讨论】:

      【解决方案3】:

      如果其他人发现此错误并出现此错误。检查参数行末尾是否有分号。适用于所有线路,而不仅仅是 proxy_pass。

      【讨论】:

        【解决方案4】:

        您错误地输入= 字符,试图以这种方式分配值时,也会发生这种情况。

        proxy_pass = http://other_node;
        

        同样的事情也可能发生在你身上,例如auth_basic = "restricted site"

        只需删除=

        【讨论】:

          猜你喜欢
          • 2017-02-19
          • 2014-01-16
          • 1970-01-01
          • 1970-01-01
          • 2017-01-21
          • 2016-01-05
          • 1970-01-01
          • 2013-06-25
          • 2016-05-01
          相关资源
          最近更新 更多