#--------------------------------------------------------------------- # 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 log /dev/log local2 chroot /var/lib/haproxy pidfile /var/run/haproxy.pid ulimit-n 262144 maxconn 100000 user haproxy group haproxy daemon nbproc 2 # 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 log global option httplog option dontlognull #option http-server-close option forceclose option http-pretend-keepalive option forwardfor except 127.0.0.0/8 option redispatch retries 3 timeout http-request 1m timeout queue 1m timeout connect 1m timeout client 5m timeout server 5m timeout http-keep-alive 10s timeout check 10s maxconn 50000 #--------------------------------------------------------------------- # main frontend which proxys to the backends #--------------------------------------------------------------------- frontend main *:8080 #acl too_many_conns be_conn(http_cache) gt 100 #acl too_many_conns2 be_conn(http_cache) gt 200 #acl limit_media path_end .mkv #acl limit_media path_end .wma ##acl limit_media path_end .aac ##acl limit_media path_end .mp3 #use_backend backups if limit_media too_many_conns #use_backend backups if too_many_conns2 #reqrep ^([^\ :]*)\ http://sdyd([abc])\.cdn\.kuwo\.cn/(.*)$ \1\ http://r\203.sycdn.kuwo.cn/\3 #reqirep ^(?i:Host):\ sdyd([abc])\.cdn\.kuwo\.cn$ Host:\ r\103.sycdn.kuwo.cn default_backend http_cache backend http_cache balance uri whole len 128 server app11 111.4.115.219:81 id 11 check inter 10s weight 2 fall 3 rise 1 server app12 111.4.115.219:82 id 12 check inter 10s weight 2 fall 3 rise 1 server app13 111.4.115.219:83 id 13 check inter 10s weight 2 fall 3 rise 1 server app14 111.4.115.219:84 id 14 check inter 10s weight 2 fall 3 rise 1 server app21 111.4.115.220:81 id 21 check inter 10s weight 2 fall 3 rise 1 server app22 111.4.115.220:82 id 22 check inter 10s weight 2 fall 3 rise 1 server app23 111.4.115.220:83 id 23 check inter 10s weight 2 fall 3 rise 1 server app24 111.4.115.220:84 id 24 check inter 10s weight 2 fall 3 rise 1 server app31 111.4.115.221:81 id 31 check inter 10s weight 2 fall 3 rise 1 server app32 111.4.115.221:82 id 32 check inter 10s weight 2 fall 3 rise 1 server app33 111.4.115.221:83 id 33 check inter 10s weight 2 fall 3 rise 1 server app34 111.4.115.221:84 id 34 check inter 10s weight 2 fall 3 rise 1 #backend backups # server backup1 127.0.0.3:91 id 1 check inter 10s weight 2 fall 3 rise 1