haproxy 配置文件详解

yum安装后的配置文件,内容仅作参考

#---------------------------------------------------------------------
# Example configuration for a possible web application.  See the
# full configuration options online.
#
#   http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
#
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
    # to have these messages end up in /var/log/haproxy.log you will
    # need to:
    #
    # 1) configure syslog to accept network log events.  This is done
    #    by adding the '-r' option to the SYSLOGD_OPTIONS in
    #    /etc/sysconfig/syslog
    #
    # 2) configure local2 events to go to the /var/log/haproxy.log
    #   file. A line like the following can be added to
    #   /etc/sysconfig/syslog
    #
    #    local2.*                       /var/log/haproxy.log
    #
    log         127.0.0.1 local2

    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000  #默认的最大连接数
    user        haproxy
    group       haproxy     daemon
    # turn on stats unix socket     stats socket /var/lib/haproxy/stats
#--------------------------------------------------------------------- # common defaults that all the 'listen' and 'backend' sections will # use if not designated in their block #--------------------------------------------------------------------- defaults     mode                    http#可选(tcp|http|health),tcp是4层,http是7层,health只会返回ok     log                     global#采用全局定义的日志     option                  httplog#日志的类别http日志格式     option                  dontlognull#不记录健康检擦的日志信息     option http-server-close     option forwardfor       except 127.0.0.0/8#如果后端服务器需要获得客户端真是ip需要的配置参数。可从http Header得到     option                  redispatch     retries                 3##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                 3000
#--------------------------------------------------------------------- # main frontend which proxys to the backends #--------------------------------------------------------------------- frontend  main *:5000#默认端口     acl url_static       path_beg       -i /static /images /javascript /stylesheets     #acl后是规则名,-i忽略大小写,i后是要访问的     acl url_static       path_end       -i .jpg .gif .png .css .js
    use_backend static          if url_static#如url_static规则被触发,就将请求分配到static     default_backend             app #不满足上面的规则就默认访问app的作用域。
#--------------------------------------------------------------------- # static backend for serving up images, stylesheets and such #--------------------------------------------------------------------- backend static     balance     roundrobin#负载均衡的模式:轮询     server      static 127.0.0.1:4331 check#后端服务器定义
#--------------------------------------------------------------------- # round robin balancing between the various backends #--------------------------------------------------------------------- backend app     balance     roundrobin     server  app1 127.0.0.1:5001 check     server  app2 127.0.0.1:5002 check     server  app3 127.0.0.1:5003 check     server  app4 127.0.0.1:5004 check     server  ng   192.168.242.133:80 check

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值