AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1068213
Accepted
gelonida
gelonida
Asked: 2021-06-30 17:13:34 +0800 CST2021-06-30 17:13:34 +0800 CST 2021-06-30 17:13:34 +0800 CST

根据源 ip 选择一个 haproxy tcp 后端

  • 772

我有基本的 haproxy 知识,并且知道如何根据 SNI 服务器名称处理 tcp 后端的选择。

相关线路是

    acl is_myhost req.ssl_sni -i my.host.com
    acl is_otherhost req.ssl_sni -i other.host.com


    use_backend mybackend if is_myhost
    use_backend otherbackend if is_otherhost

现在我想将它们更改为允许我根据源 ip 选择后端的东西,但我不知道以下伪配置的确切语法或这是否可能

    acl is_myhost_for_specif req.ssl_sni -i my.host.com <and source ip = 1.2.3.4>
    acl is_myhost_for_others req.ssl_sni -i my.host.com <and source ip != 1.2.3.4>
    acl is_otherhost req.ssl_sni -i other.host.com


    use_backend mybackend1 if is_myhost_for_specific
    use_backend mybackend2 if is_myhost_for_others
    use_backend otherbackend if is_otherhost

ssl haproxy sni
  • 1 1 个回答
  • 609 Views

1 个回答

  • Voted
  1. Best Answer
    tbielaszewski
    2021-07-02T04:35:05+08:002021-07-02T04:35:05+08:00

    您的 ACL 伪代码不正确,因为 ACL 声明没有 AND/OR 逻辑的语法。将其移至使用 ACL 的位置,如下例所示。
    对于源 IP 有src(https://cbonte.github.io/haproxy-dconv/2.2/configuration.html#7.3.3-src),例如:

    请注意,在 if 语句中匹配两个条件的语法不是

    use_backend mybackend if condition1 and condition2

    只是

    use_backend mybackend if condition1 condition2

    acl test_network src 192.168.10.0/24
    acl test_network src 192.168.20.0/24
    acl is_myhost_for_specif req.ssl_sni -i my.host.com
    
    # both acls must be true (is_myhost **and** test_network)
    use_backend mybackend1 if is_myhost test_network
    use_backend mybackend2 if is_myhost
    

    顺序use_backend很重要,因此如果 SNI 匹配,则来自test_networkgo tomybackend1和其他IP 的 IPs 去。mybackend2此处两次声明test_networkACL 表示“src_ip 匹配 192.168.10.0/24 OR 192.168.20.0/24”

    • 2

相关问题

  • 如何使用 Tomcat 5.5 更新 SSL 证书

  • 为 IIS6 自行生成 SSL 证书?

  • plesk 上的域和子域 ssl 访问

  • 如何设置 SSL 邮件服务器?

  • 如何通过 SVN 命令行接受 SSL 证书?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve