【问题标题】:Can't authenticate for NiFi/NiFi Registry instance sitting behind HAProxy server无法对位于 HAProxy 服务器后面的 NiFi/NiFi Registry 实例进行身份验证
【发布时间】:2020-12-30 19:04:34
【问题描述】:

我有一个位于 HAProxy 服务器后面的 NiFi 和 NiFi Registry 实例。 NiFi 实例均使用 SSL 保护。我无法将 SSL 信息从代理服务器传递到 NiFi 服务器。我也尝试过 SSL Passthrough,但这还有一些其他限制。

我当前的 HAProxy 配置如下所示:

frontend https_in
    bind *:443 ssl crt /etc/ssl/nifi/nifi-server.pem verify required ca-file /etc/ssl/nifi/nifi-ca.cert
    mode http
    option httplog
    option http-server-close

    acl is_registry path_beg /nifi-registry

    use_backend nifi-registry if is_registry
    default_backend nifi

backend nifi-registry
   mode http
   balance roundrobin
   http-request set-header X-Forwarded-Port %[dst_port]
   http-request set-header X-Forwarded-Proto https if { ssl_fc }
   http-request set-header X-ProxyScheme https
   http-request set-header X-ProxyHost xx.xxx.xxx.xx
   http-request set-header X-ProxyPort 443

   server registry01 172.xx.xx.xxx:18443 check ssl verify none

当我浏览到https://xx.xxx.xxx.xx:443/nifi-registry 并选择客户端证书时,我得到了 NiFi 注册表 UI,但没有使用我的客户端用户登录。我无法将我的 SSL 信息传递给 NiFi 服务器。在documentation 之后,我设置了一些标题,但它们似乎没有效果。

我在这里错过了什么吗?

编辑

因此,正如 cmets 中的建议和上面提到的,我还在 tlc 模式下尝试了 SSL Passthrough。有了这个,我设法将 SSL 身份验证传递给 NiFi 服务器,但我遇到了“无效的主机头”消息。

我的 HAProxy 配置:

frontend http_in
    bind *:80 v4v6
    mode http
    redirect scheme https if !{ ssl_fc }

frontend nifi_registry_in
    bind *:1443 v4v6
    mode tcp
    option tcplog

    tcp-request inspect-delay 5s
    tcp-request content accept if { req_ssl_hello_type 1 }

    default_backend nifi_registry

frontend nifi_in
    bind *:2443 v4v6
    mode tcp
    option tcplog

    tcp-request inspect-delay 5s
    tcp-request content accept if { req_ssl_hello_type 1 }

    default_backend nifi

backend nifi_registry
   mode tcp
   balance roundrobin
   server registry01 xxx.xx.xx.xxx:18443 check

backend nifi
    mode tcp
    balance roundrobin
    server nifi01 xxx.xx.xx.xxx:9443 check

浏览到 [public-haproxy-server-domain]:1443 时,我在身份验证后获得了注册表 ui。 浏览到 [public-haproxy-server-domain]:2443 时,身份验证后出现以下错误。

我的 NiFi 配置是

nifi.web.https.host=xxx.xx.xx.xxx
nifi.web.https.port=9443
nifi.web.https.network.interface.default=
nifi.web.jetty.working.directory=./work/jetty
nifi.web.jetty.threads=200
nifi.web.max.header.size=16 KB
nifi.web.proxy.context.path=
nifi.web.proxy.host=[public-haproxy-server-domain]:2443

【问题讨论】:

  • 您的 haproxy 配置会提取 ssl 流量 - 因此,它会替换原始客户端证书。您必须将 haproxy 模式更改为 tcp(直通)。在这种情况下,证书必须在 nifi 级别公开。
  • 当使用 tcp passthrough 时,它适用于注册表。当对 nifi 本身做同样的事情时,我得到一个“无效的主机头”,因为我的代理使用了另一个 url,而不是我在配置中指定的服务器 url。

标签: ssl apache-nifi haproxy apache-nifi-registry


【解决方案1】:

所以我已经想通了,我觉得这个真的很愚蠢。另一方面,我发现这没有很好的记录。所以我会把我的答案贴在这里给其他有需要的人。

显然要使nifi.web.proxy.host 设置起作用,还应设置nifi.web.proxy.context.path 设置。只需为此设置一个“/”作为值,一切都会按预期工作。

nifi.web.proxy.context.path=/
nifi.web.proxy.host=[public-haproxy-server-domain]:2443

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-07
    • 2019-12-16
    • 1970-01-01
    • 1970-01-01
    • 2023-02-16
    • 1970-01-01
    • 2016-02-25
    • 2014-11-08
    相关资源
    最近更新 更多