我尝试使用Haproxy 1.6.3 2015/12/25
和粘性会话。
我根据haproxy manual做了一切,但是,不幸的是,检查客户端浏览器我发现没有添加cookie(平衡器必须在第一次请求后在响应中返回cookie但它不返回任何内容没有任何结果(没有cookie))。其他一切都很完美,但饼干不是。我已经附上了我的haproxy.cfg:
global
log /dev/haproxy/log local0
log /dev/haproxy/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
stats enable
stats auth user:pass
stats uri /haproxy_stats
option httpchk HEAD / HTTP/1.0
option redispatch
balance roundrobin
frontend frontend_http
bind *:80
option forwardfor
default_backend backend_http
backend backend_http
option prefer-last-server
cookie mycookies insert indirect nocache
server server1 196.168.0.125:80 check cookie s1
server server2 196.168.0.126:80 check cookie s2
我的服务器(server1,server2)也部署在IIS
上,而balancer部署在Ubuntu 16.04 LTS
上
答案 0 :(得分:0)
更改后端配置:
backend backend_http
option prefer-last-server
cookie mycookies insert indirect nocache
server server1 196.168.0.125:80 check cookie server1
server server2 196.168.0.126:80 check cookie server2
或
backend backend_http
option prefer-last-server
cookie mycookies insert indirect nocache
server s1 196.168.0.125:80 check cookie s1
server s2 196.168.0.126:80 check cookie s2