基于haproxy-1.5.12版本的http层负载均衡代理转发,附带测试效果
2015-07-27 15:19
399 查看
——前期环境部署:
haproxy 192.168.64.129
nginx 192.168.64.129
client 192.168.64.128
(1.在server端口添加4个虚拟机 [haproxy和nginx共用一台服务器,不同端口]
(1.基于虚拟主机的转发 [实现效果:访问www.example.com将会访问192.168.64.129:8002和8003的内容]
(2.基于域名(301)跳转 [实现效果:访问www.example.com将会访问bbs.example.com的内容]
(3.基于url目录跳转 [实现效果:访问www.example.com/www/examlpe.html将会访问bbs.example.com/www/examlpe.html的内容]
(4.基于后缀以css,js结尾的静态文件文件跳转
待补充...
haproxy 192.168.64.129
nginx 192.168.64.129
client 192.168.64.128
(1.在server端口添加4个虚拟机 [haproxy和nginx共用一台服务器,不同端口]
[root@haproxy ~]# tree -n /usr/local/nginx/conf/conf.d/ /usr/local/nginx/conf/conf.d/ ├── bbs.example.com.8000.conf ├── bbs.example.com.8001.conf ├── www.example.com.8002.conf └── www.example.com.8003.conf 0 directories, 4 files [root@haproxy ~]# tree -n /usr/local/nginx/html/ /usr/local/nginx/html/ ├── bbs_8000 │ ├── index.html │ ├── index.php │ └── www │ ├── example.css │ ├── example.html │ └── example.js ├── bbs_8001 │ ├── index.html │ ├── index.php │ └── www │ ├── example.css │ ├── example.html │ └── example.js ├── www_8002 │ ├── index.html │ ├── index.php │ └── www │ ├── example.css │ ├── example.html │ └── example.js └── www_8003 ├── index.html ├── index.php └── www ├── example.css ├── example.html └── example.js 8 directories, 20 files(2.在client添加hosts信息,并访问测试域名
#添加hosts信息 [root@client ~]# tail -n2 /etc/hosts 192.168.64.129 www.example.com 192.168.64.129 bbs.example.com #访问测试域名 [root@client ~]# curl bbs.example.com:8000 bbs.example.com:8000 [root@client ~]# curl bbs.example.com:8001 bbs.example.com:8001 [root@client ~]# curl www.example.com:8002 www.example.com:8002 [root@client ~]# curl www.example.com:8003 www.example.com:8003——测试haproxy代理转发
(1.基于虚拟主机的转发 [实现效果:访问www.example.com将会访问192.168.64.129:8002和8003的内容]
frontend http_web bind 192.168.64.129:80 acl www_example_com hdr_beg(host) -i www.example.com use_backend www if www_example_com backend www balance roundrobin option httpchk HEAD /index.html server example_web01 192.168.64.129:8002 check inter 1500 rise 3 fall 3 weight 3 server example_web01 192.168.64.129:8003 check inter 1500 rise 3 fall 3 weight 3测试效果如下:
(2.基于域名(301)跳转 [实现效果:访问www.example.com将会访问bbs.example.com的内容]
frontend http_web bind 192.168.64.129:80 acl www_example_com hdr_beg(host) -i www.example.com acl bbs_example_com hdr_beg(host) -i bbs.example.com use_backend bbs if www_example_com backend bbs balance roundrobin option httpchk HEAD /index.html server example_web01 192.168.64.129:8000 check inter 1500 rise 3 fall 3 weight 3 server example_web01 192.168.64.129:8001 check inter 1500 rise 3 fall 3 weight 3测试效果如下:
(3.基于url目录跳转 [实现效果:访问www.example.com/www/examlpe.html将会访问bbs.example.com/www/examlpe.html的内容]
frontend http_web bind 192.168.64.129:80 acl www_example_com hdr_beg(host) -i www.example.com acl bbs_example_com hdr_beg(host) -i bbs.example.com acl www_path path_beg -i /www use_backend bbs_pool if bbs or www_path backend bbs_pool balance roundrobin option httpchk HEAD /index.html server example_web01 192.168.64.129:8000 check inter 1500 rise 3 fall 3 weight 3 server example_web01 192.168.64.129:8001 check inter 1500 rise 3 fall 3 weight 3测试效果如下:
(4.基于后缀以css,js结尾的静态文件文件跳转
frontend http_web bind 192.168.64.129:80 acl www_example_com hdr_beg(host) -i www.example.com acl bbs_example_com hdr_beg(host) -i bbs.example.com acl www_static path_end -i .js .css use_backend bbs if www_static backend bbs balance roundrobin option httpchk HEAD /index.html server example_web01 192.168.64.129:8000 check inter 1500 rise 3 fall 3 weight 3 server example_web01 192.168.64.129:8001 check inter 1500 rise 3 fall 3 weight 3测试效果如下:
待补充...
相关文章推荐
- 负载均衡技术沙龙1期(关于咱的图片)
- 负载均衡沙龙活动第二期现场问答汇集
- 浅谈sqlserver的负载均衡问题
- PHP开发负载均衡指南
- Win2003利用dfs(分布式文件系统)在负载均衡下的文件同步配置方案
- LVS+Keepalived构建高可用负载均衡(测试篇)
- 简单测试Apache是如何完成负载均衡策略配置
- Apache负载均衡设置方法 mod_proxy使用介绍
- LVS(Linux Virtual Server)Linux 虚拟服务器介绍及配置(负载均衡系统)
- linux服务器之LVS、Nginx和HAProxy负载均衡器对比总结
- Shell脚本实现把进程负载均衡到多核CPU中
- tomcat6_apache2.2_ajp 负载均衡加集群实战分享
- [Oracle] RAC 之 - 负载均衡深入解析
- windows NLB+ARR实现Web负载均衡高可用/可伸缩的方法
- haproxy+keepalived实现高可用负载均衡(理论篇)
- 理解web服务器和数据库的负载均衡以及反向代理
- haproxy+keepalived实现高可用负载均衡(实例配置)
- 用apache和tomcat搭建集群(负载均衡)
- LVS+Keepalived构建高可用负载均衡配置方法(配置篇)