一、错误重定向
1、
vim /etc/haproxy/haproxy.cfg
acl badhost src 172.25.1.250
block if badhost
errorloc 403 http:/172.25.1.1:8000
systemctl restart haproxy
网页测试:
http://172.25.1.1:8000 #服务器拒绝访问并且重定向到指定位置
2、301重定向
vim /etc/haproxy/haproxy.cfg
acl westos.org hdr_beg(host) -i westos.org
acl 172.25.1.1 hdr_beg(host) -i 172.25.1.1
#识别westos.org和172.25.0.1两个地址
redirect code 301 location http://www.westos.org if westos.org
redirect code 301 location http://www.westos.org if 172.25.1.1
在真机做解析
网页测试:
172.25.1.1–直接自定义搜索www.westos.org。显示搜索172.25.1.1内容(RSserver2)
二、读写分离
1、配置过程
vim /etc/haproxy/haproxy.cfg
acl read method GET
acl read method HEAD #两个read write只用一个就行
acl write method PUT
acl write method POST
RS:
yum install php -y
上传php文件
vim upload_file.php
chmod 777 upload_file.php
2、测试页面