Download 64-bit haproxy1.5, unzip, modify folder config file
The configuration file haproxy.cfg the following contents:
######### #全局配置 ######### Global daemon Nbproc 1 pidfile/haproxy1.5/run/haproxy.pid #ulimit-n 82000 #设置每个进程的可用的最大文件描述符 # Log 127.0.0.1 local0 #日志输出配置, all logs are recorded on the local machine, through local0 output #log 127.0.0.1 local1 notice #log loghost local0 info #ulimit-N 8200 0 #设置每个进程的可用的最大文件描述符 #maxconn 4096 #最大连接数 #chroot/var/haproxy #chroot运行的路径 #uid He #所属运行的用户uid a #gid #所属运行的用户组 Emon #以后台形式运行haproxy #nbproc 1 #进程数量 (you can set up multiple processes to improve performance) #pidfile/var/run/haproxy.pid #haproxy的pid存放路径, the user who started the process must have permission to access the file #d Ebug #调试模式, the output boot information to the standard output #quiet #安静模式, boot without output ####### #默认配置 ############ defaults mode http #默认的模式mode {tcp|http|health}, TCP is a layer 4, HTTP is 7, health only returns OK retries 2 #两次连接失败就认为是服务器不可用, you can also set Maxconn 1000 #默认的最大连接数 #option httplog #日志类别 by following the Using Httplog #option httplog #日志类别http日志格式 #option httpclose #每次请求完毕后主动关闭http通道 #option dontlognull #不记录健康检查的日志信息 #option
Forwardfor #如果后端服务器需要获得客户端真实ip需要配置的参数, you can obtain client IP option Redispatch #当serverId对应的服务器挂掉后 from the HTTP header, and force directed to other healthy servers Option Abortonclose #当服务器负载很高的时候 to automatically end the current queue processing comparisonLong links #stats Refresh #统计页面刷新间隔 #balance roundrobin #默认的负载均衡的方式, polling way #balance source #默认的负载均衡的方式, similar to the ip_hash of Nginx #bala
NCE leastconn #默认的负载均衡的方式, minimum connection timeout connect 5000ms #连接超时 timeout client 30000ms #客户端超时 Timeout server 30000ms #服务器超时 #timeout Check 2000 #= heartbeat timeout log 127.0.0.1 local0 err #[err warning Info Debug] ####### #统计页面配置 ######## Listen Admin_stat s #Frontend和Backend的组合体, name of the Monitoring group, on-demand custom name bind 0.0.0.0:8088 #监听端口 mode http #http的7层模式 option Httplog #采用http日志格式 #log 127. 0.0.1 local0 err maxconn stats refresh 30s #统计页面自动刷新时间 stats uri/stats #统计页面url, URL of the monitor page stats realm xingcloud\ Hapro XY #统计页面密码框上提示文本, monitor page prompts stats auth admin:admin #统计页面用户名和密码设置, monitor page user and password admin, can set multiple user names #stats auth admin1:admin1 # User and password for the monitor page admin1 stats hide-version #隐藏统计页面上HAProxy的版本信息 #stats admin if TRUE #手工启用/disable, back-end server (later version haproxy-1.4.9) #errorf Ile 403/etc/haproxy/errorfiles/403.http #errorfile 500/etc/haproxy/errorfiles/500.http #errorfile 502/etc/haproxy/ Errorfiles/502.http #errorfile503/etc/haproxy/errorfiles/503.http #errorfile 504/etc/haproxy/errorfiles/504.http ####### #test1配置 ############### # # Listen test1 bind 0.0.0.0:9999 mode tcp #maxconn 4086 #log 127.0.0.1 local0 Debug Server S1 0.0.0.0:8086 weight 2 Check Inter 30000 #server S2 192.168.1.156:8001 #server S3 192.168.1.156:8002 ####### #frontend配置 ############## ####### #test2配 ################# Listen test2 bind 0.0.0.0:9111 mode tcp #maxconn 4086 #log 127.0.0.1 local0 Debug Server S4 0.0.0.0:900 0 Weight 1 Check Inter 30000 server S5 0.0.0.0:9001 weight 5 Check Inter 30000 #server S5 192.168.1.156:9001 #server S6 19 2.168.1.156:9002 ####### #frontend配置 ##############IIS site configuration as shown:
Then use the cmd command under DOS:
CD xx:\yyyyyyy\haproxy1.5
Enter in the extracted path
Haproxy.exe-f haproxy.cfg-d
As pictured, disregard warning information:
Then enter the Web administration address in the browser, the specific URL look at the configuration file, username and password are admin
Web Site Access Example: