Haproxy负载web服务配置

global
        maxconn         65535  #并发最大连接数量
        stats socket    /var/run/haproxy.stat mode 600 level admin
        log             127.0.0.1 local0
        uid             99                  #用户  必须是本机查看显示的id
        gid             99                  #组
        chroot          /var/empty
        daemon                              #后台运行
defaults
        mode            http            #默认使用 http 的 7 层模式 tcp: 4 层
        log             global
        option          httplog            #http 日志格式
        option          dontlognull        #禁用空链接日志
        monitor-uri     /monitoruri
        maxconn         8000
        timeout client  300s
        retries         2
        option redispatch
        timeout connect 300s
        timeout server  300s
        stats uri       /admin/stats   #haproxy 监控页面
# The public 'www' address in the DMZ
 
frontend public
        bind            172.25.27.1:8001 name clear
        #use_backend     static if { hdr_beg(host) -i img }
        #use_backend     static if { path_beg /img /css   }
        default_backend dynamic

# The static backend backend for 'Host: img', /img and /css.

backend dynamic
   option forwardfor
   mode http
   cookie SERVERID insert indirect nocache #基于cookie做负载均衡
   server web1 127.0.0.1:10080 cookie web1 check inter 1500 rise 3 fall 3 weight 1
   server web2 127.0.0.2:10080 cookie web2 check inter 1500 rise 3 fall 3 weight 1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值