zoukankan      html  css  js  c++  java
  • haproxy代码

    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

           #option  httpchk HEAD /index.html HTTP/1.0 基于head检测url
            option  httpchk GET /index.html #基于请求get检测url

            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

  • 相关阅读:
    2016"百度之星"
    codeforces 55 div2 C.Title 模拟
    codeforces 98 div2 C.History 水题
    codeforces 97 div2 C.Replacement 水题
    codeforces 200 div2 C. Rational Resistance 思路题
    bzoj 2226 LCMSum 欧拉函数
    hdu 1163 九余数定理
    51nod 1225 余数的和 数学
    bzoj 2818 gcd 线性欧拉函数
    Codeforces Round #332 (Div. 2)D. Spongebob and Squares 数学
  • 原文地址:https://www.cnblogs.com/allmdzz/p/11146236.html
Copyright © 2011-2022 走看看