Haproxy 配置 session 粘贴

范堡 发布于 2010/03/03 16:37
阅读 3K+
收藏 3
haproxy 配置session粘连

我使用TOMCAT6.0分别开启了8080和8081端口的应用
前面是haproxy做LOADBALANCE的代理
配置文件如下:

global
log 127.0.0.1 daemon debug
maxconn 4096
pidfile /usr/local/haproxy/logs/haproxy.pid
daemon
defaults
log global
stats uri /stats
stats auth sillycat:kaishi
mode http
option dontlognull
retries 3
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000
listen     webhttp 0.0.0.0:80
mode http
option httpchk GET /demo/ping.jsp
cookie DEMOCOOKIE insert nocache
balance roundrobin
server app1 127.0.0.1:8080 cookie app1inst1 check
server app2 127.0.0.1:8081 cookie app2inst2 check

分别在两个TOMCAT上启动两个应用,一个easystatic是些静态页面,一个easylogon,需要cookies登陆访问

global
log 127.0.0.1 daemon debug
maxconn 4096
pidfile /usr/local/haproxy/logs/haproxy.pid
daemon
defaults
log global
stats uri /admin/status
stats auth sillycat:kaishi
mode http
option dontlognull
retries 3
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000
frontend http-in
    bind 0.0.0.0:80
    mode http
    log global
    option httplog
    option httpclose
    option forwardfor
    capture request header Host len 20
    capture request header User-Agent len 16
    capture request header Content-Length len 10     
    capture request header Referer        len 20
    capture response header Content-Length len 10
    acl api_logon url_sub -i logon
    acl api_static url_sub -i static
            acl stat_req url_dir -i admin
    block if !api_logon !api_static !stat_req
use_backend logon_server if api_logon
use_backend static_server if api_static
default_backend static_server
backend logon_server
   mode http
option httpchk GET /easylogon/ping.jsp
   balance roundrobin
   cookie LOGONCOOKIE insert nocache
   server app1 127.0.0.1:8080 cookie app1inst1 check
server app2 127.0.0.1:8081 cookie app2inst2 check
backend static_server
   mode http
option httpchk GET /easystatic/ping.jsp
   server app3 127.0.0.1:8080 weight 3 check
server app4 127.0.0.1:8081 weight 3 check
加载中
0
员外
你用haproxy来做负载均衡,主要是针对什么样的应用服务器?
返回顶部
顶部