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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值