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 / 问题 / 973586
Accepted
wazoox
wazoox
Asked: 2019-07-02 08:48:26 +0800 CST2019-07-02 08:48:26 +0800 CST 2019-07-02 08:48:26 +0800 CST

haproxy 1.7 重定向和拒绝某些 IP

  • 772

要将同一 IP 上的多个子域重定向到不同的主机,我使用的是 haproxy(1.7.5,Debian stable),它工作正常。但是,我还想通过 IP 限制对某些主机的访问,并向被拒绝的主机显示一条干净的消息(正确的 403 错误页面),这就是我找不到解决方案的地方。

到目前为止,我最好的配置是使用“拒绝”后端的配置;但是我不知道如何配置这个以从浏览器端获取除了 SSL 错误之外的任何内容。

配置如下所示:

frontend http_redirect
    bind *:80
    redirect scheme https if !{ ssl_fc }

frontend tls_router
    bind *:443
    mode tcp
    option tcplog
    option tcpka

    acl demo_acl req_ssl_sni -i demo.myhost.org
    acl www_acl req_ssl_sni -i www.myhost.org
    acl demo_network_allowed src 10.1.1.0/24

    use_backend demo_tls if demo_acl
    use_backend wwww_tls if www_acl
    use_backend reject_access if demo_acl !demo_network_allowed

backend www_tls
    mode tcp
    option tcpka
    server www_srv 192.168.1.2:443

backend demo_tls
    mode tcp
    option tcpka
    server demo_srv 192.168.1.3:443

backend reject_access
    mode http
    # errorfile 403 /etc/haproxy/errors/403.http
    # server demo  192.168.1.2:443
    http-request set-path www.myhost.org/403.html
    http-request redirect scheme https if ! { ssl_fc }

从“reject_access”后端可以清楚地看出,我尝试了几件事,结果相同:

$ LANG=C wget  --no-check-certificate -S https://demo.myhost.org
--2019-07-01 18:48:31--  https://demo.host.org/
Résolution de demo.myhost.org? 10.12.24.1
Connexion à demo.myhost.org|10.12.24.1|:443? connecté.
OpenSSL: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
Incapable d'établir une connexion SSL.

欢迎对此配置提供任何帮助。

https
  • 1 1 个回答
  • 353 Views

1 个回答

  • Voted
  1. Best Answer
    dario
    2019-07-02T11:49:42+08:002019-07-02T11:49:42+08:00

    您不能在 tcp 模式下更改 ssl 请求的 url。您必须在 haproxy 中终止 ssl

    错误说它无法建立 ssl 连接。拒绝后端向 443 发出 http 请求

    编辑,SSL 终止示例

    frontend https443
            bind *:443 ssl crt someWildacrd.pem
            #http-request set-log-level silent
    
            #SSL is terminated, we can see URL path
            acl restricted_page path_beg,url_dec -i /admin
            http-request deny if restricted_page
    
            default_backend b_http
    
    • 2

相关问题

  • 为 IIS 7.0 问题创建证书

  • IE6 和更高版本在 HTTPS 处理方面的差异

  • 如何模拟连接到 HTTPS 并记录握手?

  • SSL 错误:ssl_error_bad_mac_read

  • 在实时站点上使用自签名证书有什么好处?

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