模范配置文件
#--------------------------------------------------------------------- # Global settings #--------------------------------------------------------------------- global log 127.0.0.1 local3 maxconn 204800 chroot /usr/local/haproxy user haproxy group haproxy daemon nbproc 1 pidfile /var/run/haproxy.pid stats socket /usr/local/haproxy/stats description haproxy server #--------------------------------------------------------------------- # common defaults that all the 'listen' and 'backend' sections will # use if not designated in their block #--------------------------------------------------------------------- defaults log global mode http maxconn 10000 option httplog option httpclose option dontlognull option forwardfor except 127.0.0.0/8 retries 3 option redispatch option abortonclose balance roundrobin timeout http-request 10s timeout queue 1m timeout connect 10s timeout client 1m timeout server 1m timeout http-keep-alive 10s timeout check 10s #--------------------------------------------------------------------- # use listen setting the haproxy status for site #--------------------------------------------------------------------- listen admin_status #设置haproxy监控状态 bind *:3030 mode http log 127.0.0.1 local3 err stats refresh 5s stats uri /status #监控状态页面访问url stats realm www.skeryp.com stats auth admin:admin stats hide-version stats admin if TRUE #--------------------------------------------------------------------- # main listen which proxys to the backends #--------------------------------------------------------------------- listen www bind *:80 maxconn 5000 mode http log global option httplog option httpclose option forwardfor log global default_backend default #设置默认访问页面 #定义当请求的内容是静态内容时,将请求转交给static server的acl规则 acl url_static path_beg -i /static /images /img /javascript /stylesheets acl url_static path_end -i .jpg .gif .png .css .js .html acl host_static hdr_beg(host) -i img. video. download. ftp. imags. videos. #定义当请求的内容是php内容时,将请求转交给php server的acl规则 acl url_php path_end -i .php #定义当请求的内容是.jsp或.do内容时,将请求转交给tomcat server的acl规则 acl url_jsp path_end -i .jsp .do #引用acl匹配规则 use_backend static_pool if url_static or host_static use_backend php_pool if url_php use_backend tomcat_pool if url_jsp #定义后端backend server backend static_pool option httpchk GET /index.html server static1 192.168.0.247:80 cookie id1 check inter 2000 rise 2 fall 3 backend php_pool option httpchk GET /info.php server php1 192.168.0.235:80 cookie id1 check inter 2000 rise 2 fall 3 backend tomcat_pool option httpchk GET /index.jsp server tomcat1 192.168.0.238:8086 cookie id2 check inter 2000 rise 2 fall 3 #<----------------------default site for listen and frontend------------------------------------> backend default mode http option httpchk GET /index.html server default 192.168.0.127:80 cookie id1 check inter 2000 rise 2 fall 3 maxconn 5000
转载于:https://www.cnblogs.com/soymilk2019/p/11055917.html