90 acl badhost src 172.25.88.250
91 block if badhost
92 errorloc 403 :8000badhost(172.25.88.250)在浏览器中访问172.25.88.1 自动跳转到:8000
黑名单重定向
server1:
acl badhost src 172.25.88.250
redirect location :8000 if badhostbadhost(172.25.88.250)在浏览器中访问172.25.88.1 自动跳转到:8000
RS全挂了以后(302临时重定向)
server4:
/etc/init.d/httpd stop
server1:
vim /etc/haproxy
103 backend app
104 balance roundrobin
105 server web2 172.25.88.4:80 check
106 server local 172.25.88.1:8000 backup访问172.25.88.1,跳转到8000 显示工程师正在修复ING(页面需要自己写)
网易:301 永久重定向 cdn
302 临时重定向,不推荐
server1:
vim /etc/haproxy
94 redirect code 301 location :8000 if badhost如果不写301,只写code默认是302,临时重定向
网页重定向
1.访问westos.org自动跳转到
真机:
vim /etc/hosts
172.25.88.1 server1.lalala.com westos.orgserver1:
vim /etc/haproxy
acl westos.org hdr_beg(host) -i westos.org
redirect code 301 location if westos.org
2.访问IP自动跳转到域名
server1:
vim /etc/haproxy
acl 172.25.88.1 hdr(host) -i 172.25.88.1
redirect code 301 location if 172.25.88.1
读写分离
server11:
vim /etc/haproxy
106 acl read method GET
107 acl read method HEAD
108 acl write method PUT
109 acl write method POST
119 use_backend app if write
120 default_backend static
123 backend static
124 balance roundrobin
125 server web1 172.25.88.3:80 check 读
126
127 backend app
128 balance roundrobin
129 server web2 172.25.88.4:80 check 写server3,server4:
yum install php -y cd /var/www/html/upload/
mv * ..
chmod 777 upload
server3和server4的upload都有读写权限哦~
记得将upload中的size改大一点.
&& ($_FILES["file"]["size"] < 20000000))/etc/init.d/httpd restart 因为装了php模块,还是重启一下吧~
检测
在浏览器中访问
因为只有server3中有images ,server4中没有,所以读端在server3
上传图片(写)在server4的upload中
尽管server3,server4的upload都是777
HAproxy的基本配置(负载均衡+日志独立+动静分离+读写分离)
CentOS 7下Keepalived + HAProxy 搭建配置详解