shawnmei 发表于 2019-1-2 09:16:04

HAproxy配置指令简单总结之一

  haproxy配置分为两部分
  global
  proxies
  default
  frontend
  backend
  listen = frontend + backend
  

  

  global
进程管理及安全相关的参数
chroot
pidfile
user
uid
group
gid
log
daemon  

性能调整相关的参数
maxconn
noepoll
nopoll  

debug相关参数
debug  

  

  proxies 需要注意使用的位置 backend、frontend、listen、default
  

balance --> roundrobin static-rr leastconn source uri uri-param hdr()
bind
mode
hash-type
    map-based --> 取模 用key的hash值对server总数取模,
    consistent --> 一致性hash
      一致性hash算法除了计算key的hash值外,还会计算每个server对应的hash值,
      然后将这些hash值映射到一个有限的值域上(比如0~2^32)
log
maxconn
default_backend
server[:prot]
capture request headerlen
capture response header
stats enable
stats uri
stats realm
stats auth
stats hide-version
stats admin
option forwardfor [ header] [ if-none ]
errorfile
    errorfile 400 /etc/haproxy/errorpages/400badreq.http
    errorfile 403 /etc/haproxy/errorpages/403forbid.http
    errorfile 503 /etc/haproxy/errorpages/503sorry.http
timeout client :
timeout server
timeout connect
timeout http-keep-alive
timeout client-fin
timeout server-fin   

  

  

  ACL简单指令说明
acl acl_name criterion flags op value  

  criterion
dst
dst_port
src
src_port --> 4层
hdr
method
path_beg
path_end
hdr_beg
hdr_end--> 7层  

  flags
-i  

  op
eq:等于
ge;大于等于
gt:大于
le:小于等于
lt:小于
=:等于  

  访问控制相关的参数
http-request { allow | deny}[ { if | unless }]
tcp-request content[{if | unless} ]
   
      "accept", "reject",  




页: [1]
查看完整版本: HAproxy配置指令简单总结之一