haproxy1.8.x源码编译安装

下载安装haproxy-1.8.2.tar.gz 
官网下载地址:https://www.haproxy.org/
解压haproxy-1.8.2.tar.gz 
tar -zxvf haproxy-1.8.2

查看系统内核版本
uname -r

make TARGET=linux2632 PREFIX=/usr/local/haproxy18

make install PREFIX=/usr/local/haproxy18

cp -rf /usr/local/haproxy18/sbin/haproxy /usr/sbin/

查看安装的haproxy版本

创建系统服务启动方式(在源码包中的examples文件夹下拷贝,并相应修改内容)

vim /etc/init.d/haproxy修改相应的内容与之匹配

创建haproxy配置文件vim /etc/haproxy/haproxy.cfg
global
        log     127.0.0.1 local0
        maxconn 4000
        ulimit-n 80170
        #uid     500
        #gid     500
        user xiaofeng  #使用uid也可以
        group xiaofeng
        #chroot  /usr/local/haproxy
        nbproc  1
        daemon
        pidfile  /usr/local/haproxy18/haproxy.pid
        stats socket  /var/run/haproxy.sock
#       debug
#       quiet
 
defaults
        log     127.0.0.1       local3
        mode    http
        option  httplog
        option  httpclose
        option  dontlognull
        option  abortonclose
        option  forwardfor
        option  redispatch
        retries 2
        maxconn 2000
        balance roundrobin
        timeout connect      5000
        timeout check   20000
        timeout client     150000
        timeout server      150000
 
 
listen stats
        bind 0.0.0.0:10081
        mode    http
        log     127.0.0.1 local0 err
        stats   uri     /hastats
        stats auth    admin:admin
        stats refresh 30s
        stats hide-version
        #option httpchk GET /Login.d
 
frontend http_80
        option forwardfor
        bind :80
        mode http
        maxconn 1500
        log     global
        option httplog
        # log the name of the virtual server
        capture request header Host len 30
        # log the beginning of the referrer
        capture request header Referer len 50
 
        acl  test  hdr_beg(host) -i  test.proxy.com

        use_backend zone_test  if test
 
backend  zone_test
        mode http
        option forwardfor
        option httpchk GET / HTTP/1.1\r\nHost:test.proxy.com
        server web01 192.168.0.103:80 check inter 9000 rise 3 fall 3
        server web02 192.168.0.104:80 check inter 9000 rise 3 fall 3
启动haproxy服务service haproxy start

查看haproxy监控状态



写的较好的haproxy博客和文档:
http://www.ttlsa.com/linux/haproxy-study-tutorial/
https://www.cnblogs.com/heiye123/articles/7928292.html
https://www.cnblogs.com/shanyou/archive/2012/10/16/2726768.html
http://blog.51cto.com/freeloda/1294094
https://www.cnblogs.com/zhangs1986/p/6517788.html






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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值