无法对位于 HAProxy 服务器后面的 NiFi/NiFi 注册表实例进行身份验证

Can't authenticate for NiFi/NiFi Registry instance sitting behind HAProxy server

我有一个 NiFi 和 NiFi Registry 实例位于 HAProxy 服务器后面。 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 and select the client certificate I get the NiFi Registry UI but not logged in with my client user. I am not able to pass my SSL information to the NiFi servers. Following the documentation 时,我设置了一些 header,但它们似乎没有效果。

我是不是遗漏了什么?

编辑

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

我的 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

所以我已经弄清楚了,但我觉得这件事真的很愚蠢。另一方面,我没有找到很好的记录。所以我会post在这里为其他有需要的人回答。

显然要使 nifi.web.proxy.host 设置生效,还应设置 nifi.web.proxy.context.path 设置。只需为此输入一个“/”作为值,一切都会按预期进行。

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