- 需求说明
服务器介绍:
HAProxy Server: 192.168.1.90
WEB1 : 192.168.1.103
WEB2 : 192.168.1.105
Domain: tecadmin.net
当用户访问:tecadmin.net/blog链接,只会跳转到WEB2(192.168.1.105)服务器.
而其他所有的访问将根据权值跳转到WEB1或者WEB2服务器 - 配置文件
global
log 127.0.0.1 local0 notice
maxconn
daemon
defaults
log global
mode http
option httplog
option dontlognull
contimeout
clitimeout
srvtimeout
option forwardfor
option http-server-close # Configuration for HTTP site
frontend http-in
bind 192.168.1.90:
acl is_blog url_beg /blog
use_backend tecadmin_blog if is_blog
default_backend tecadmin_website backend tecadmin_blog
mode http
balance roundrobin # Load Balancing algorithm
option httpchk
option forwardfor
server WEB2 192.168.1.105: weight maxconn check backend tecadmin_website
mode http
balance roundrobin # Load Balancing algorithm
option httpchk
option forwardfor
server WEB1 192.168.1.103: weight maxconn check
server WEB2 192.168.1.105: weight maxconn checkhaproxy Code
- 参考链接:http://tecadmin.net/haproxy-acl-for-load-balancing-on-url-request/