nginx“proxy_pass”指令中的参数数量无效

use*_*593 6 django nginx

nginx: [emerg] invalid number of arguments in "proxy_pass" directive in /etc/nginx/sites-enabled/django_direct:12
Run Code Online (Sandbox Code Playgroud)

我的 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;
    }
}
Run Code Online (Sandbox Code Playgroud)

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

proxy_pass http://unix:/root/django_direct/django_direct.sock;
Run Code Online (Sandbox Code Playgroud)

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

小智 24

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


Inr*_*rin 3

您的论点是错误的。\n它需要一个 URL:

\n\n
\n

设置代理服务器的协议和地址以及位置应映射到的可选 URI。作为协议,可以指定 \xe2\x80\x9chttp\xe2\x80\x9d 或 \xe2\x80\x9chttps\xe2\x80\x9d。地址可以指定为域名或 IP 地址,以及可选端口:

\n\n

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

\n\n

或者作为在单词 \xe2\x80\x9cunix\xe2\x80\x9d 之后指定并用冒号括起来的 UNIX 域套接字路径:

\n\n

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

\n
\n\n

请参阅文档:http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass

\n