【问题标题】:Haproxy Session TransferHaproxy 会话传输
【发布时间】:2015-05-19 21:56:27
【问题描述】:

我们有一个 haproxy 来平衡两台服务器 app1 和 app2 的负载。我们为每一个设置了权重,例如 app1 的权重为 255,而另一个 app2 的权重为 0。如果任何情况下 app1 出现故障,如何将会话和连接无缝传输到 app。有没有我们可以通过haproxy实现它。我们将在下面附上我们的 haproxy 配置,请指导我们

global
    log         127.0.0.1 local0
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    stats socket /etc/haproxy/haproxysock level admin
    daemon defaults
    mode        http
    log         global
    option      dontlognull
    option      http-server-close
    option      httplog
    option      redispatch
    timeout connect 10000 
    timeout client 300000
    timeout server 300000
    maxconn     60000
    retries     3
    stats uri /haproxy_stats
    stats realm HAProxy\ Statistics
    stats auth hadmin:unMetric_2012

frontend  main *:5000
    acl is_app      path_beg       -i /static /images /javascript /stylesheets /js
    acl is_app      path_end       -i .jpg .gif .png .css .js
    acl is_app      path_end       -i /app/
    use_backend app             if is_app
    default_backend             app backend static
    balance     roundrobin
    server      static 127.0.0.1:4331 check backend app    option httpchk GET /app
    balance    roundrobin
     reqrep ^([^\ :]*)/app((/?.*)*)    \1/app\2
      cookie uid preserve indirect
     stick-table type string len 40 size 5M expire 60m
    stick store-response set-cookie(sid) table app    stick on cookie(sid) table app
    stick on url_param(sid) table app    server  app1   demo1.unmetric.com:8080 cookie s1 weight 255 check
    server  app2  demo2.unmetric.com:8080 cookie s2 weight 0 check

【问题讨论】:

    标签: haproxy


    【解决方案1】:

    haproxy 不处理您的后端应用会话复制。
    它使用 cookie 或请求参数来实现粘性,但您的后端应用程序应自行处理其会话复制。

    【讨论】:

      猜你喜欢
      • 2015-11-11
      • 1970-01-01
      • 2018-12-07
      • 2014-07-16
      • 2014-09-30
      • 2016-12-07
      • 2016-08-09
      • 2011-06-16
      • 1970-01-01
      相关资源
      最近更新 更多