社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  NGINX

nginx proxy_pass:“使用http://app_server;或http:/x.x.x:8000/uri/的参数数目无效;

WebRyan • 5 年前 • 523 次点击  

我使用的是nginx、django和gunicorn,在我的nginx站点启用配置中,我一直在获取代理传递行上的错误无效参数数量。我相信根据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 . 我甚至尝试使用代理通行证 http://xxx.xxx.xx.xxx:8000 ;仍然是同样的错误。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/38110
 
523 次点击  
文章 [ 1 ]  |  最新文章 5 年前
WebRyan
Reply   •   1 楼
WebRyan    6 年前

我就是这样解决的。我先添加了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;
        }