Proxy configuration can be located in a set of sections :
defaults <name>
frontend <name>
backend <name>
listen <name>
A "defaults" section sets default parameters for all other sections following
its declaration. Those default parameters are reset by the next "defaults"section. See below for the list of parameters which can be set in a "defaults"section. The name is optional but its use is encouraged for better readability.
A "frontend" section describes a set of listening sockets accepting clientconnections.
A "backend" section describes a set of servers to which the proxy will connectto forward incoming connections.
A "listen" section defines a complete proxy with its frontend and backend
parts combined in one section. It is generally useful for TCP-only traffic.
All proxy names must be formed from upper and lower case letters, digits,'-' (dash), '_' (underscore) , '.' (dot) and ':' (colon). ACL names arecase-sensitive, which means that "www" and "WWW" are two different proxies.
bind
绑定ip及端口
bind [<address>]:<port_range> [, ...] [param*]
bind /<path> [, ...] [param*]
Define one or several listening addresses and/or ports in a frontend.
Specify a method to use for mapping hashes to servers
May be used in sections :
defaults frontend listen backend
yes no yes yes
<method>
map-based:除权取余法,哈希数据结构是静态的数组;
consistent:一致性哈希,哈希数据结构是一个树;
<function> is the hash function to be used : 哈希函数
sdbm
djb2
wt6
<modifier>
avalanche
default_backend
default_backend <backend>\
Specify the backend to use when no "use_backend" rule has been matched.
May be used in sections :
defaults frontend listen backend yes yes yes no
例
use_backend dynamic if url_dyn
use_backend static if url_css url_img extension_img
default_backend dynamic
server
server <name> <address>[:[port]] [param*]
Declare a server in a backend 定义后端主机及其各种选项
May be used in sections :
defaults frontend listen backend no no yes yes