其他分享
首页 > 其他分享> > haproxy中的session保持实现

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

标签:haproxy,option,rise,192.168,server,session,保持,fall,backend
来源: https://www.cnblogs.com/liulj0713/p/10801660.html