站长资讯网
最全最丰富的资讯网站

nginx反向代理报错400

当用nginx做负载均衡的时候,nginx的配置文件如下:

      upstream server_pools {           server 10.0.0.7:80  weight=1;           server 10.0.0.8:80  weight=1;  

当客户端访问时出现报错如下:

  [root@lb02 ~]# curl  www.hahaetiantian.org    

Bad Request

Your browser sent a request that this server could not understand.

Additionally, a 400 Bad Request error was encountered while trying to use an ErrorDocument to handle the request.

[root@lb02 ~]# curl www.hahaetiantian.org www

查看日志报错并不能找到原因,但是根据400报错以及对http协议的原理了解得知是因为请求头的原因,最后在网上找到解决办法,原因是因为upstream后面的名称有下划线使得代理无法识别,修改如下:

      upstream server-pools {           server 10.0.0.7:80  weight=1;           server 10.0.0.8:80  weight=1;

然后再次访问结果如下:

  [root@lb02 ~]# curl  www.etiantian.org  apache www  [root@lb02 ~]# curl  www.etiantian.org  www

赞(1)
分享到: 更多 (0)
网站地图   沪ICP备18035694号-2    沪公网安备31011702889846号