免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4636 | 回复: 5
打印 上一主题 下一主题

[Web] haproxy1.4.22请求头http1.1响应头http1.0 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-10-24 14:59 |只看该作者 |倒序浏览
本帖最后由 stormcc 于 2012-10-24 15:04 编辑

近来折腾haproxy,测试中发现我使用IE和curl发送请求头中为http1.1,但是haproxy的响应头是http1.0。
后来尝试1.4.22,1.4.21,1.4.19都相同效果。【曾尝试在listen配置块添加:no option httpclose指令仍然不行。】
不知道大家有没有遇到过这状况,怎么解决的。
如下:
# curl http://10.10.77.67/car/120/32/65/Img1646532_120.jpg -H host:m2.auto.it.cn  -o /dev/null -v
* About to connect() to 10.10.77.67 port 80 (#0)
*   Trying 10.10.77.67... connected
* Connected to 10.10.77.67 (10.10.77.67) port 80 (#0)
> GET /car/120/32/65/Img1646532_120.jpg HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.13.1.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2
> Accept: */*
> host:m2.auto.it.cn
>
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: nginx/0.8.55
< Date: Thu, 18 Oct 2012 09:04:20 GMT
< Content-Type: image/jpeg
< Content-Length: 4634
< Last-Modified: Wed, 25 Jul 2012 02:35:21 GMT
< Expires: Sun, 16 Oct 2022 09:04:20 GMT
< Cache-Control: max-age=315360000
< Accept-Ranges: bytes
< Age: 67409
< X-Cache: HIT from 106_213.auto.it.cn
< Via: 1.1 106_213.auto.it.cn:81 (squid/2.7.STABLE9)
< Connection: close
<
{ [data not shown]
100  4634  100  4634    0     0  1216k      0 --:--:-- --:--:-- --:--:-- 4525k* Closing connection #0

论坛徽章:
0
2 [报告]
发表于 2012-10-24 15:01 |只看该作者
详细配置文件如下:
# grep -v ^'#' haproxy.cfg                  
global
    log    127.0.0.1 local3 info
    maxconn     8000
    ulimit-n 16014
    user  haproxy
    group haproxy
    chroot    /opt/haproxy1.4.22/
    pidfile /opt/haproxy1.4.22/logs/haproxy.pid
    nbproc 1   
    daemon

defaults
    mode http
    log global
    option httplog
    timeout connect 10s
    timeout client  10s
    timeout server  10s
    timeout check   2s

listen .auto.it.cn
    bind *:80
    log global
    option httplog
    monitor-net 192.168.106.0/24
    monitor-uri /haproxy.test
    balance   uri
    log    127.0.0.1 local0 debug
    hash-type consistent  
    server cache2 192.168.106.109:81 check inter 1500 rise 3 fall 3 weight 12
    server cache3 192.168.106.213:81 check inter 1500 rise 3 fall 3 weight 12
    http-check send-state
    fullconn 6000
    retries    3
    option redispatch
    option httpchk GET /flag.txt  HTTP/1.0\nHost:\ m1.auto.it.cn
    http-check expect status 200

listen haproxystat
    bind  *:6501
    stats enable
    stats uri   /haproxy-stats  
    stats realm Haproxy/Statistics
    stats auth  admin:admin
    stats hide-version

论坛徽章:
0
3 [报告]
发表于 2012-10-24 16:21 |只看该作者
----刚刚找到问题原因了

我的haproxy后端是squid,抓包发现squid请求其后端的nginx源服务器是http1.0的头,从而其后端返回给squid的响应头也是http1.0。squid将该http1.0的响应返回给了haproxy,haproxy将响应头为http1.0的结果响应给客户端。

将squid去掉,haproxy后端直连nginx后,haproxy发送给nginx http1.1的头,同时接收到nginx1.1的响应头,然后将http1.1的响应返回给客户端。。

是测试中使用的squid没支持http1.1导致的。

论坛徽章:
0
4 [报告]
发表于 2012-10-30 15:55 |只看该作者
学习了~~一样的架构

论坛徽章:
0
5 [报告]
发表于 2012-10-30 15:56 |只看该作者
楼主有没有出现squid经常down的情况?

论坛徽章:
0
6 [报告]
发表于 2012-11-02 09:39 |只看该作者
qqsosoad 发表于 2012-10-30 15:56
楼主有没有出现squid经常down的情况?


我一直用squid2.7stable9(很老),咱没有发现挂掉,只遇到过 squid -k shutdown 关闭不成功情况。
你的是什么版本?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP