haproxy(二)配置session粘连

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

你可能感兴趣的:(tomcat,jsp)