GlobalLog127.0.0.1local0 chroot/var/lib/haproxy #chroot运行路径 pidfile/var/run/haproxy.pid #haproxy Process pid file Maxconn65535#默认最大连接数, you need to consider ulimit-N Limit user haproxy group Haproxy daemon #以后台形式运行harpoxy tune.s SL. default-dh-param 2048 SSL-server- Verify none stats socket/var/lib/haproxy/statsdefaults option forwardfor option httpclose option do Ntlognull #不记录健康检查日志信息 Option Redispatch #当serverId对应的服务器挂掉后, Force-directed to other healthy servers that will not be supported in the future retries 3#两次连接失败就认为是服务器不可用, you can also set the timeout Connect 10s #连接超时 timeout client 50s #客户端超时 Timeout Server 50s #服务器超时 Maxconn65535#默认最大连接数, you need to consider ulimit-n Limit ####### #统计页面配置 ####### #listen admin_stats bind0.0.0.0: the#设置Frontend和Backend的组合体, the name of the Monitoring group, customize the name as needed mode HTTP #http的7层模式 stats r Efresh 30s #统计页面自动刷新时间 stats URI/haproxy #统计页面url Stats Realm cloud\haproxy #统计页面密码框上提示文本 stats auth admin:admin #设 User and password for the monitoring page: admin, you can set multiple user names stats hide-version #隐藏统计页面上HAProxy的版本信息 stats adminifTRUE #设置手工启动/disabled, back-end server (haproxy-1.4. 9 later versions) ####### #frontend前端配置 ##################### #backend后端配置 ############# #listen http_80 bind0.0.0.0: themode http balance leastconn logGlobalLog-format"%tl",%{+q}ci,"%FI:%FP",%{+q}bi,%{+q}r,%st,%b,%{+q}hr,%Tt option httpclose option forwardfor option HTTP-server-Close Capture request header Host Len255Capture Request Header User-agent Len255Capture Request Header Referer Len255Capture Request Header Cookie Len255Timeout http-Request 50s Timeout HTTP-keep-Alive 55s Server http_80_web1_80192.168.6.15: theCookie web1_80 WeightTenCheck Inter theRise3Fall5Server http_80_web2_80192.168.6.16: theCookie web2_80 WeightTenCheck Inter theRise3Fall5ACL ericdress_com HDR (host)-m str ericdress.com redirect prefix http://www.ericdress.com Code 301 if ericdress_com####### #tcp配置 ################ #listen https_443 bind *:443 SSL crt/etc/ssl/certs/ERIC.PEM #需要设置证书文件的位置 mode HTTP option httpclose option Forwardfor REQA DD X-forwarded-proto:\ https #增加http头 capture request header Host Len 255 Capture Request Header User-agent len 255 Capture request header Referer Len 255 Capture RE Quest Header Cookie Len 255 Timeout http-Request 50s Timeout HTTP-keep-Alive 55s server http_443_web1_443 192.168. 6.15:443 SSL Cookie web1_443 weight check Inter rise 3 Fall 5< /c11> server http_443_web2_443 192.168. 6.16:443 SSL Cookie web2_443 weight check Inter rise 3 FAL L 5
Haproxy configuration supports HTTPS get User IP address