zoukankan      html  css  js  c++  java
  • 基于URL的HAProxy负载均衡设置

    例子包括ACL的url_beg。 url_beg提交URL中使用的字符串相匹配。

    使用URL /blog(cnblog/api)所有请求重定向到WEB服务器的6200端口。所有其他请求将重定向到服务器的6100端口,根据负载均衡使用的算法。 下面是使用url_beg ACL的一个简单的例子:

    global
    	#log /dev/log	local6
    	log 192.168.1.110:51405 local7
    	maxconn 100000
    	uid 99
    	gid 99
    	daemon
    	stats   socket /var/run/haproxy.stat mode 644
    	quiet
    
    defaults
    	log	global
    	mode	http
    	option	httplog
    	option	dontlognull
    	option	httpclose
    	option	forceclose
    	option	forwardfor
    	option	redispatch
    	option	allbackups
    	option	http-server-close
    	option	log-health-checks
    	retries	3
    	balance	roundrobin
    	maxconn	20000
    	timeout connect	10000
    	timeout client	50000
    	timeout server	50000
    	timeout	check	10000
    
    listen haproxy-statistics
    	bind	0.0.0.0:11180
    	stats	enable
    	stats	admin	if TRUE
    	stats	refresh	30s
    	stats	hide-version
    	stats	uri	/haproxy-status
    	stats	realm	Haproxy statistics
    	stats	auth	deed:6ddu7
    
    listen haproxy-monitoring
    	bind	0.0.0.0:11190
    	mode	health
    	monitor-net	192.168.1.0/24
    	no option	forceclose
    	no option	httpclose
    	no option	http-server-close
    frontend api.cnblog.cn:6200
      bind *:6200
      mode http
      acl api.cnblog.cn       url_beg   /api
      use_backend api.cnblog.cn     if api.cnblog.cn
      default_backend  api_cnblog.cn
    backend api.cnblog.cn
      mode http
      balance roundrobin
      #cookie SERVERID insert indirect nocache
      #option  httpchk GET /alived.gif  HTTP/1.1
    Host: api.cnblog.cn
      server  tomcat_10.211           192.168.1.211:6200     check inter 10000 rise 2 fall 3
      server  tomcat_10.212           192.168.1.212:6200     check inter 10000 rise 2 fall 3
    backend api_cnblog.cn
      mode http
      balance roundrobin
      #cookie SERVERID insert indirect nocache
      #option  httpchk GET /alived.gif  HTTP/1.1
    Host: api.cnblog.cn
      server  tomcat_10.211           192.168.1.211:6100     check inter 10000 rise 2 fall 3
      server  tomcat_10.212           192.168.1.212:6100     check inter 10000 rise 2 fall 3
    

      

  • 相关阅读:
    TUN/TAP区别
    从日志文件解决ArcGIS Server性能低下问题的步骤(1)
    java异常
    Maven
    前车之鉴-web篇
    图论复习总结
    奇(qi)谋(ji)巧(yin)计(qiao)
    莫比乌斯反演呓语
    学习后缀数组笔记
    浅读叶青学长竞赛学习知识目录
  • 原文地址:https://www.cnblogs.com/xzlive/p/9057766.html
Copyright © 2011-2022 走看看