免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: Godbach
打印 上一主题 下一主题

【负载均衡大讨论,参与有礼】TCP/HTTP 负载均衡利器-- HAProxy [复制链接]

论坛徽章:
1
IT运维版块每日发帖之星
日期:2016-04-09 06:20:00
91 [报告]
发表于 2016-04-07 13:52 |只看该作者
回复 85# Godbach


    listen 0.0.0.0:1111
        bind :1111
        mode http
        server mirrors mirrors.163.com:80
我的配置很简单
就是转发到163,
我看了数据好像就是转发不到163网站上去

论坛徽章:
36
IT运维版块每日发帖之星
日期:2016-04-10 06:20:00IT运维版块每日发帖之星
日期:2016-04-16 06:20:0015-16赛季CBA联赛之广东
日期:2016-04-16 19:59:32IT运维版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-19 06:20:00每日论坛发贴之星
日期:2016-04-19 06:20:00IT运维版块每日发帖之星
日期:2016-04-25 06:20:00IT运维版块每日发帖之星
日期:2016-05-06 06:20:00IT运维版块每日发帖之星
日期:2016-05-08 06:20:00IT运维版块每日发帖之星
日期:2016-05-13 06:20:00IT运维版块每日发帖之星
日期:2016-05-28 06:20:00每日论坛发贴之星
日期:2016-05-28 06:20:00
92 [报告]
发表于 2016-04-07 14:05 |只看该作者
回复 90# coldgin

在你 HAProxy 所在的机器上,抓一下 tcp port 80 的报文。看看是否有你的请求通过 HAproxy 转发出去了。

我刚才测试一下代理 CU 的 BBS 是可以拿到页面的。

还有一个细节你要注意,测试的时候,要让 Host 还是你代理的域名。否则对方的网站会 403。


   

论坛徽章:
36
IT运维版块每日发帖之星
日期:2016-04-10 06:20:00IT运维版块每日发帖之星
日期:2016-04-16 06:20:0015-16赛季CBA联赛之广东
日期:2016-04-16 19:59:32IT运维版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-19 06:20:00每日论坛发贴之星
日期:2016-04-19 06:20:00IT运维版块每日发帖之星
日期:2016-04-25 06:20:00IT运维版块每日发帖之星
日期:2016-05-06 06:20:00IT运维版块每日发帖之星
日期:2016-05-08 06:20:00IT运维版块每日发帖之星
日期:2016-05-13 06:20:00IT运维版块每日发帖之星
日期:2016-05-28 06:20:00每日论坛发贴之星
日期:2016-05-28 06:20:00
93 [报告]
发表于 2016-04-07 14:08 |只看该作者
回复 90# coldgin

我测试的反向代理 CU 的核心配置如下:
frontend fe
        bind 127.0.0.1:9000
        default_backend be

backend be
        balance static-rr
        server 1 bbs.chinaunix.net:80 cookie rs1


测试请求如下:
wget 'http://127.0.0.1:9000/forum-224-1.html' --header="Host: bbs.chinaunix.net"


结果如下:
$wget 'http://127.0.0.1:9000/forum-224-1.html' --header="Host: bbs.chinaunix.net"
--2016-04-07 14:06:56--  http://127.0.0.1:9000/forum-224-1.html
Connecting to 127.0.0.1:9000... connected.
HTTP request sent, awaiting response... 200 OK
Cookie coming from 127.0.0.1 attempted to set domain to 127.0.0.1
Cookie coming from 127.0.0.1 attempted to set domain to 127.0.0.1
Cookie coming from 127.0.0.1 attempted to set domain to 127.0.0.1
Cookie coming from 127.0.0.1 attempted to set domain to 127.0.0.1
Cookie coming from 127.0.0.1 attempted to set domain to 127.0.0.1
Cookie coming from 127.0.0.1 attempted to set domain to 127.0.0.1
Cookie coming from 127.0.0.1 attempted to set domain to 127.0.0.1
Cookie coming from 127.0.0.1 attempted to set domain to 127.0.0.1
Length: unspecified [text/html]
Saving to: “forum-224-1.html.1”

    [ <=>                                                                                    ] 113,122      730K/s   in 0.2s

2016-04-07 14:06:57 (730 KB/s) - “forum-224-1.html.1” saved [113122]

论坛徽章:
1
IT运维版块每日发帖之星
日期:2016-04-09 06:20:00
94 [报告]
发表于 2016-04-07 16:33 |只看该作者
回复 92# Godbach


    应该是被对方拒绝了。
我的测试方法是在,同一个局域网内用Win下的IE测试的,返回404
我抓包看过了,TCP连接都是OK的,说明反代配置正常。



我的需求是想打算用haproxy来实现反代上网,不知道能不能实现。
看到网上有介绍nginx能反代google

论坛徽章:
36
IT运维版块每日发帖之星
日期:2016-04-10 06:20:00IT运维版块每日发帖之星
日期:2016-04-16 06:20:0015-16赛季CBA联赛之广东
日期:2016-04-16 19:59:32IT运维版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-19 06:20:00每日论坛发贴之星
日期:2016-04-19 06:20:00IT运维版块每日发帖之星
日期:2016-04-25 06:20:00IT运维版块每日发帖之星
日期:2016-05-06 06:20:00IT运维版块每日发帖之星
日期:2016-05-08 06:20:00IT运维版块每日发帖之星
日期:2016-05-13 06:20:00IT运维版块每日发帖之星
日期:2016-05-28 06:20:00每日论坛发贴之星
日期:2016-05-28 06:20:00
95 [报告]
发表于 2016-04-07 16:35 |只看该作者
回复 93# coldgin

你是通过 IP 直接访问,还是修改 host,通过域名的方式访问?

   

论坛徽章:
0
96 [报告]
发表于 2016-04-08 17:36 |只看该作者

论坛徽章:
0
97 [报告]
发表于 2016-04-12 11:56 |只看该作者
HAProxy的特点是:
1、HAProxy是工作在网络7层之上。
2、能够补充Nginx的一些缺点比如Session的保持,Cookie的引导等工作
3、支持url检测后端的服务器出问题的检测会有很好的帮助。
4、负载均衡策略很多:动态加权轮循(Dynamic Round Robin),加权源地址哈希(Weighted Source Hash),加权URL哈希和加权参数哈希(Weighted Parameter Hash)已经实现
5、单纯从效率上来讲HAProxy更会比Nginx有更出色的负载均衡速度。
6、HAProxy可以对Mysql进行负载均衡,对后端的DB节点进行检测和负载均衡。
最开始用的haproxy ,后来换成了nginx
性能上感觉负载软件lvs>haproxy>nginx

评分

参与人数 1可用积分 +6 收起 理由
Godbach + 6 赞一个!

查看全部评分

论坛徽章:
36
IT运维版块每日发帖之星
日期:2016-04-10 06:20:00IT运维版块每日发帖之星
日期:2016-04-16 06:20:0015-16赛季CBA联赛之广东
日期:2016-04-16 19:59:32IT运维版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-19 06:20:00每日论坛发贴之星
日期:2016-04-19 06:20:00IT运维版块每日发帖之星
日期:2016-04-25 06:20:00IT运维版块每日发帖之星
日期:2016-05-06 06:20:00IT运维版块每日发帖之星
日期:2016-05-08 06:20:00IT运维版块每日发帖之星
日期:2016-05-13 06:20:00IT运维版块每日发帖之星
日期:2016-05-28 06:20:00每日论坛发贴之星
日期:2016-05-28 06:20:00
98 [报告]
发表于 2016-04-12 14:41 |只看该作者
回复 96# gaoyp27

最开始用的haproxy ,后来换成了nginx

换成 nginx 的原因是什么,是有其他需求 HAProxy 不能满足了吗?

性能上感觉负载软件lvs>haproxy>nginx


用 LVS 和 HAProxy/Nginx 比较没有太大意义,四层和七层的区别,而且功能侧重点也不一样。

   

论坛徽章:
0
99 [报告]
发表于 2016-04-13 09:23 |只看该作者

当时查询了一下资料,haproxy 的资料比较老旧,没有nginx的资料多而且较全。
再加上当时着急使用,做了一点对比后就选用了nginx

   

论坛徽章:
36
IT运维版块每日发帖之星
日期:2016-04-10 06:20:00IT运维版块每日发帖之星
日期:2016-04-16 06:20:0015-16赛季CBA联赛之广东
日期:2016-04-16 19:59:32IT运维版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-19 06:20:00每日论坛发贴之星
日期:2016-04-19 06:20:00IT运维版块每日发帖之星
日期:2016-04-25 06:20:00IT运维版块每日发帖之星
日期:2016-05-06 06:20:00IT运维版块每日发帖之星
日期:2016-05-08 06:20:00IT运维版块每日发帖之星
日期:2016-05-13 06:20:00IT运维版块每日发帖之星
日期:2016-05-28 06:20:00每日论坛发贴之星
日期:2016-05-28 06:20:00
100 [报告]
发表于 2016-04-13 11:21 |只看该作者
回复 98# gaoyp27

是的。HAProxy 社区整体上不够活跃:一来不支持模块开发,二来可能也是功能单一有关系,只做负载均衡,不像 nginx,还能多做 server 用。


   
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP