首页 > 其他 > 详细

haproxy代码

时间:2019-07-07 15:20:34      阅读:117      评论:0      收藏:0      [点我收藏+]

1,haproxy定义cookie并且返回数据给客户端,让客户端第二次请求这个域名下的页面时带上haproxy定义的cookie跟数值(key-value)

global
    log         127.0.0.1 local2
    chroot      /var/lib/haproxy pidfile /var/run/haproxy.pid
    maxconn     40000
    user        haproxy
    group       haproxy
    daemon
    stats socket /var/lib/haproxy/stats

defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000

① 定义web 监控页面
listen stats
bind 0.0.0.0:1080
stats enable
stats hide-version
stats uri /haproxyadmin  监控页面的详细地址
stats auth admin:admin  验证的账号密码
stats admin if TRUE

② 在frontend 段定义ACL
frontend web

        bind :80
        acl staticfile path_end .jpg .png .bmp .htm .html .css .js  定义静态页面acl
        acl appfile path_end .php
        use_backend staticsrvs if staticfile
        default_backend appsrvs

③ 设置backend 后端集群组

backend staticsrvs

balance roundrobin

server staticweb 192.168.30.107:80 check inter 3000 rise 3 fall 3

backend appsrvs
        balance roundrobin

        cookie SRV insert nocache
        server appweb1 192.168.30.7:80 check inter 3000 rise 3 fall 3 cookie srv1

        server appweb2 192.168.30.7:80 check inter 3000 rise 3 fall 3 cookie srv2

haproxy代码

原文:https://www.cnblogs.com/allmdzz/p/11146236.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!