haproxy中的session保持实现

1.在client增加cookie

backend backend_www
    option forwardfor
    cookie SERVERID insert indirect nocache  #插入session信息
    option     redispatch  #当后端rs挂了,可立即切换,不会出现503错误
    option httpchk HEAD / HTTP/1.0
    balance roundrobin
    server www1 192.168.1.198:80 cookie www1check inter 2000 rise 30 fall 15
    server www2 192.168.1.52:80 cookie www2 checkinter 2000 rise 30 fall 15
 

2.balance source 根据原ip,经过hash计算后,指定后端固定的rs

backend backend_www
    option forwardfor
    option httpchk HEAD / HTTP/1.0
    balance source
    server www1 192.168.1.198:80 check inter2000 rise 30 fall 15
    server www2 192.168.1.52:80check inter 2000 rise 30 fall 15

原文:https://blog.51cto.com/chboy/1768133
上一篇:php – 在另一个SQL查询中执行SQL查询


下一篇:错误MSB4018 “ResolvePackageAssets”任务意外失败的解决方法