Haproxy粘稠会话

时间:2018-05-03 07:55:11

标签: iis ubuntu-16.04 load-balancing haproxy

我尝试使用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

1 个答案:

答案 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