【问题标题】:Nginx proxy_pass :"invalid number of arguments using http://app_server; or http:/x.x.x.x:8000/uri/;Nginx proxy_pass :"使用 http://app_server 的参数数量无效;或 http:/x.x.x.x:8000/uri/;
【发布时间】:2018-09-24 22:43:43
【问题描述】:

我正在使用 nginx、django 和 gunicorn,并且在启用了 nginx 站点的配置中的 proxy_pass 行上不断收到错误无效的参数数量。根据 nginx 文档,我相信这是正确的方法。我哪里错了?我真的被困住了。

upstream app_server{
   server xxx.xxx.xx.xxx:8000 fail_timeout=0;
}
location @proxy_to_app {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Host $http_host
    proxy_redirect off;
    proxy_pass http://app_server;   

    }

我检查了以下解决方案@[类似问题][1],但它没有回答为什么上面的配置不起作用[1]:nginx invalid number of arguments in "proxy_pass" directive。 我什至尝试使用 proxy_pass http://xxx.xxx.xx.xxx:8000;还是一样的错误。

【问题讨论】:

    标签: nginx


    【解决方案1】:

    可能通过添加 ;到 $hppt_host

    【讨论】:

      【解决方案2】:

      我就是这样解决的。我在其他参数之前先添加了 proxy_pass 和 proxy_redirect off。

      location @proxy_to_app {
                proxy_pass http://app_server;
                proxy_redirect off;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header Host $http_host;
              }
      

      【讨论】:

      • 顺序无关紧要。您已经通过其他方式解决了您的问题。
      猜你喜欢
      • 2019-01-06
      • 1970-01-01
      • 1970-01-01
      • 2011-01-27
      • 1970-01-01
      • 2020-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多