- 论坛徽章:
- 0
|
本帖最后由 silmark 于 2017-12-23 21:01 编辑
我用haproxy做的负载器(Centos7,haproxy1.8.1),负载IP是10.121.1.180 ,真实服务器是121.1.68-70(win2008+IIS),
客户端win7x64, IE11。
访问语句如下:
http://10.121.1.180/dthealth/web ... Adm=19&deposittype=住院押金
访问时会返回http 400错误,无法找到该网页。
但是我直接连真实服务器,就完全正常。
后来我试着把URL的参数“&deposittype=住院押金“删掉后,在负载下手动去连接也是正常打开的。但是我不可能去改他们的程序代码。
目前暂且发现这一个问题,其他页面还没发现错误。
错误日志:Dec 23 20:20:34 localhost haproxy[16645]: 10.121.9.2:10483 [23/Dec/2017:20:20:34.241] HIS_SERV HIS_SERV/<NOSRV> -1/-1/-1/-1/0 400 187 - - PRNN 1/1/0/0/3 0/0 {||} {||} "<BADREQ>"
【已经解决了,从本论坛找到的,加了一个参数 option accept-invalid-http-request #允许接受无效的http请求,一般建议不设置,但是可解决部分杂牌浏览器访问打不开页面问题。】
论坛原话:http://bbs.chinaunix.net/thread-4241432-15-1.html
Godbach 版主在142楼发表的:
。。。这个问题一方面就是 IE 比较 low。好像是 URL 中含有本地语言的话,URL 的编码他就是用本地系统语言来编码 URL。而 Chrome 之类的好像会转成 UTF8。
HAProxy 缺省情况下仅支持标准的 URL,显然不能包含非 ASCII 码。但是 HAproxy 同时提供了一个选项 option accept-invalid-http-request,让 HAProxy 可以让一些本来是非法的 request,当做正常的处理。
你需要的应该是开启这个选项。。。。
##############修改后的haproxy配置如下:############################
#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
log 127.0.0.1 local2 ###[err warning info debug]
chroot /usr/local/haproxy
pidfile /var/run/haproxy.pid ###haproxy的pid存放路径,启动进程的用户必须有权限访问此文件
maxconn 4000 ###最大连接数,默认4000
user haproxy
group haproxy
daemon ###创建1个进程进入deamon模式运行。此参数要求将运行模式设置为"daemon"
#tune.bufsize 128000 #这个参数是报错后加上的,不过有没有这个参数也一样报400错误
#tune.http.maxhdr 10000 ##这个参数是报错后加上的,不过有没有这个参数也一样报400错误
#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
mode http ###默认的模式,tcp是4层,http是7层,health只会返回OK 若是混合模式则 mode 不需要设置
log global ###采用全局定义的日志
option dontlognull ###不记录健康检查的日志信息
option accept-invalid-http-request #允许接受无效的http请求,一般建议不设置,但是可解决部分杂牌浏览器访问打不开页面问题。
option httpclose ###每次请求完毕后主动关闭http通道
#option http-server-close
option httplog ###日志类别http日志格式 混合模式 此处还需要加上 tcplog
option forwardfor except 127.0.0.0/8 ###如果后端服务器需要获得客户端真实ip需要配置的参数,可以从Http Header中获得客户端ip
option redispatch ###serverId对应的服务器挂掉后,强制定向到其他健康的服务器
timeout http-request 10s #HTTP请求超时
timeout connect 10s #default 10 second timeout if a backend is not found
timeout client 10s ###客户端连接超时
timeout server 10s ###服务器连接超时
maxconn 6000 ###最大连接数
retries 3 ###3次连接失败就认为服务不可用,也可以通过后面设置
########统计页面配置########
listen admin_stats
# 监听端口
bind 0.0.0.0:8089
# 启用状态监控
stats enable
mode http
log global
# 统计页面URL
stats uri /stats
# 统计页面密码框上提示文本
stats realm Haproxy\ Statistics
# 统计页面用户名和密码设置
stats auth admin:admin
# 隐藏统计页面上HAProxy的版本信息
#stats hide-version
#当通过认证才可管理
stats admin if TRUE
#统计页面自动刷新时间
stats refresh 30s
listen HIS_SERV
bind 0.0.0.0:80
mode http
option httplog
option httpchk HEAD / HTTP/1.1\r\nHost:localhost
log global
cookie SRV_ID insert indirect nocache
server HIS68 10.121.1.68:80 cookie 1 check inter 1000 weight 1 rise 2 fall 3
server HIS69 10.121.1.69:80 cookie 2 check inter 1000 weight 1 rise 2 fall 3
server HIS70 10.121.1.70:80 cookie 3 check inter 1000 weight 1 rise 2 fall 3
errorfile 403 /etc/haproxy/errorfiles/403.http
errorfile 500 /etc/haproxy/errorfiles/500.http
errorfile 502 /etc/haproxy/errorfiles/502.http
errorfile 503 /etc/haproxy/errorfiles/503.http
errorfile 504 /etc/haproxy/errorfiles/504.http
########################结 ~~ 束######################################
|
|