Centos7.1 1503最小化安裝,nginx和haproxy通過yum安裝,關閉防火牆,清空iptables
haproxy主機ip:192.168.70.161
後端nginx主機ip:192.168.70.158,192.168.70.159
一、配置haproxy,只保留到defaults,下面的修改爲如下
frontend main *:80 acl test2 hdr_beg(host) -i node2.linuxu.me //acl設定匹配請求的url acl test3 hdr_beg(host) -i node3.linuxu.me use_backend node2 if test2 use_backend node3 if test3 default_backend node2 backend node2 //設置兩臺後端nginx服務器 balance roundrobin server node2 192.168.70.159:80 check backend node3 balance roundrobin server node3 192.168.70.158:80 check
二、分別在nginx原index.html添加h1字段以區別,注意是在head裏分別添加
node2 <h1>node2.linuxu.me</h1> node3 <h1>node3.linuxu.me</h1>
三、添加host文件並訪問測試