apache+haproxy负载均衡实例

haproxy-windows-1.7.8

Apache配置

Listen 81

Listen 82

<VirtualHost *:80>

    DocumentRoot "D:\phpStudy\PHPTutorial\WWW"

    ServerName www.t.com

    ServerAlias

  <Directory "D:\phpStudy\PHPTutorial\WWW">

      Options FollowSymLinks ExecCGI

      AllowOverride All

      Order allow,deny

      Allow from all

     Require all granted

  </Directory>

</VirtualHost>

<VirtualHost *:81>

    DocumentRoot "E:\php\haproxy1"

    ServerName www.ha1.com

    ServerAlias

  <Directory "E:\php\haproxy1">

      Options FollowSymLinks ExecCGI

      AllowOverride All

      Order allow,deny

      Allow from all

     Require all granted

  </Directory>

</VirtualHost>

 

Haproxy配置

#

global
	log 127.0.0.1 local0
	log 127.0.0.1 local1 notice
	log 127.0.0.1 local2 err
	maxconn 500
	nbproc  1
	daemon

defaults
		log global
        mode http
        retries 3
		option httplog
        option dontlognull
		retries 3
        maxconn 32000
		option redispatch
        timeout connect 300000ms
        timeout client  300000ms
        timeout server  300000ms


listen win_ss 
        bind 127.0.0.1:10008
        mode    http
		option  httplog
		maxconn 100
        balance roundrobin
        server  s1 127.0.0.1:81 weight 1 maxconn 2000 inter 60s check rise 1 fall 3 
		server  s2 127.0.0.1:82 weight 1 maxconn 2000 inter 60s check rise 1 fall 3
		server  s3 127.0.0.1:80 weight 1 maxconn 2000 inter 60s check rise 1 fall 3  
		
frontend weblb	
		bind 127.0.0.1:80
		acl is_www hdr_beg(host)  www.t.com
		acl is_ip  hdr_beg(host)  127.0.0.1
		acl is_sip src            127.0.0.1
		
		use_backend server1 if is_www
		use_backend serverip if is_ip is_sip
		default_backend backend_default
		
backend server1
		balance roundrobin
		server www1 127.0.0.1:81 weight 1 maxconn 2000 inter 60s check rise 1 fall 3 
		server www2 127.0.0.1:82 weight 1 maxconn 2000 inter 60s check rise 1 fall 3 
		server www3 127.0.0.1:80 weight 1 maxconn 2000 inter 60s check rise 1 fall 3

backend serverip
		server www5 127.0.0.1:81
				
backend backend_default
		server www6 127.0.0.1:82

listen status
    bind 0.0.0.0:1188
    mode http                   
    stats refresh 30s
    stats uri  /  
    stats auth admin:admin
    #stats hide-version
    stats admin if TRUE

 

http://127.0.0.1:10008/访问

http://127.0.0.1:1188/监控

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值