由于没有没备案,服务器机房80端口是不对外开放,估此下面使用801端口做为出口端口使用
#yum -y install haproxy
#cd /etc/haproxy/
#cp haproxy.cfg haproxy.cfg.bak
#echo ''>haproxy.cfg
#vi haproxy.cfg
第一种形式为多域名。链接转发
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 51200
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 50000
frontend web_in
mode http
maxconn 50000
bind :80
acl is_a hdr_beg(host) -i www.需要判断的域名.com
acl is_b hdr_beg(host) -i m.需要判断的域名.com
acl is_c hdr_beg(host) -i www.需要跳转重定向的域名.com
use_backend a_server if is_a
use_backend b_server if is_b
use_backend c_server if is_c
backend a_server
mode http
balance roundrobin
option httpclose
option forwardfor
server phpinfo1 源ip地址:801
backend b_server
mode http
balance roundrobin
option httpclose
option forwardfor
server phpinfo1 源ip地址:801
backend c_server
mode http
balance roundrobin
option httpclose
option forwardfor
#server phpinfo1 zxdowncom.oss-cn-shanghai.aliyuncs.com
server phpinfo1 任何ip都可以:801 redir http://需要转向的域名
第二种形式为所有域名直接定向80端口转发
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 51200
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 50000
#监控反向代理的端口
listen webinfo :80
mode http
balance roundrobin
option httpclose
option forwardfor
option httpchk HEAD /123.html HTTP/1.0
server phpinfo1 源ip地址:801
期待你的留言
已有( 0 )条评论*验证码: