• haproxy acl访问限制IP


    http-request: 7层过滤

    tcp-request content: tcp层过滤,四层过滤
     
    注意   四层 采用 accept和reject    七层采用 allow和deny      方式和规则名称均不一样
     
    详细见配置文件
     

    global
    log 127.0.0.1 local2

    chroot /var/lib/haproxy
    pidfile /var/run/haproxy.pid
    nbproc 1
    maxconn 8000
    user haproxy
    group haproxy
    daemon

    #stats socket /var/lib/haproxy/stats

    defaults
    mode tcp
    log global
    option tcplog
    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 15m
    timeout server 15m
    #timeout http-keep-alive 10s
    timeout check 10s
    maxconn 6000

    listen admin_stats
    bind 0.0.0.0:9188
    mode http
    log 127.0.0.1 local3 err
    #HAProxy监控页面统计自动刷新时间。
    stats refresh 30s
    #设置监控页面URL路径。 http://IP:9188/haproxy-status可查看
    stats uri /haproxy
    #统计页面密码框提示信息
    stats realm welcome login Haproxy
    #登录统计页面用户和密码
    stats auth admin:123456
    #隐藏HAProxy版本信息
    stats hide-version
    #设置TURE后可在监控页面手工启动关闭后端真实服务器
    #stats admin if TRUE
    #设置允许访问的IP段
    acl allow_host src 10.0.0.0/8
    http-request allow if allow_host
    #拒绝其他IP的http请求
    http-request deny

    frontend api1
    bind *:80
    mode tcp
    log global
    #设置允许访问的IP段
    acl allow_host src 10.0.0.0/8
    tcp-request content accept if allow_host
    #拒绝其他IP的http请求
    tcp-request content reject
    default_backend api1pool

    backend api1pool
    balance roundrobin
    server api1 10.10.10.101:80 check inter 2000 rise 2 fall 3 maxconn 3000
    server api2 10.10.10.102:80 check inter 2000 rise 2 fall 3 maxconn 3000

  • 相关阅读:
    semantic-ui 容器与栅格
    semantic-ui 分段
    semantic-ui 分割线
    semantic-ui 图片
    semantic-ui 标题
    semantic-ui 图标
    semantic-ui 按钮
    PHP实现无限级分类
    后端修改配置文件后,前端刷新页面--搭配鉴权
    上线新系统后,统计从旧系统切换到新系统的数据
  • 原文地址:https://www.cnblogs.com/liqing1009/p/10044127.html
Copyright © 2020-2023  润新知