在Docker容器中运行时如何配置Apache NiFi nifi.web.proxy.host?

问题描述 投票:0回答:1

我已经使用命令成功地在容器中启动了Apache NiFi

docker run --name nifi -p 9090:9090 -d -e NIFI_WEB_HTTP_PORT='9090' apache/nifi:latest

并且可以连接到http://localhost:9090/nifi上的UI-但是,我的公司仅允许子网之间的HTTPS连接,因此我使用Nginx通过以下配置将对https的调用反向代理到NiFi容器:

location /nifi/ {
    proxy_set_header X-ProxyScheme "https";
    proxy_set_header X-ProxyHost "mercury-dev";
    proxy_set_header X-ProxyPort "443";
    proxy_set_header X-ProxyContextPath "/nifi/";
    proxy_pass http://mercury-dev:9090/nifi/;
}
location /nifi-docs/ {
    proxy_set_header X-ProxyScheme "https";
    proxy_set_header X-ProxyHost "mercury-dev";
    proxy_set_header X-ProxyPort "443";
    proxy_set_header X-ProxyContextPath "/nifi-docs/";
    proxy_pass http://mercury-dev:9090/nifi-docs/;
}
location /nifi-api/ {
    proxy_set_header X-ProxyScheme "https";
    proxy_set_header X-ProxyHost "mercury-dev";
    proxy_set_header X-ProxyPort "443";
    proxy_set_header X-ProxyContextPath "/nifi-api/";
    proxy_pass http://mercury-dev:9090/nifi-api/;
}

当我从远程计算机浏览到https://mercury-dev/nifi时,NiFi UI开始加载,然后失败。屏幕错误显示An unexpected error has occurred. Please check the logs for additional details.,Chrome开发者控制台报告:

/nifi-api/access/kerberos:1 Failed to load resource: the server responded with a status of 409 (Conflict)
/nifi-api/access/oidc/exchange:1 Failed to load resource: the server responded with a status of 409 (Conflict)
/nifi-api/flow/about:1 Failed to load resource: the server responded with a status of 500 (Internal Server Error)
/nifi-api/flow/process-groups/root:1 Failed to load resource: the server responded with a status of 500 (Internal Server Error)

[当我登录到容器并查看日志文件时,看到许多错误,例如ERROR [NiFi Web Server-21] org.apache.nifi.web.util.WebUtils The provided context path [/nifi-api] was not whitelisted

我在NiFi documentation中找到了使用nifi.web.proxy.hostnifi.web.proxy.context.path属性将主机和内容列入白名单的参考,但是我找不到如何执行的描述。

  • 在容器中,没有可用的编辑器来编辑属性文件(无论如何,这都是很糟糕的做法)
  • 文档中提到通过UI的“全局”菜单进行设置,但我认为没有明显的选择。
  • 我也许能够向容器命令行提供环境变量,但是找不到任何引用来执行此操作,因此找不到要使用的变量名。

如何设置这些属性,或者使此容器在HTTPS代理后面运行?

docker nginx reverse-proxy apache-nifi
1个回答
0
投票

Docker容器并未公开您需要直接针对此用例进行修改的所有设置,因此您有一些选择(对应于已编号的点)。

(常规)似乎您提供了多个上下文路径的配置,但没有提供root path/)。如文档中所述,NiFi应用程序内部有许多组件上下文路径,因此当将其放置在代理之后时,应该使用根路径。

  1. [正确,基本Docker映像中没有编辑器。您可以基于此图像构建自己的图像(使用编辑器或使用自定义属性/脚本来处理这种情况)。
  2. 您链接到的文档正在讨论授予外部代理中继请求的权限。您可以在NiFi中将代理身份添加为用户,以通过UI授予其权限。这不同于识别NiFi应用程序的代理服务(nifi.properties设置)。无法配置通过用户界面列出的这两个设置。
  3. 当前Docker start.sh文件列出了Docker映像此时接受的环境变量。要添加更多,请提交PR或start.sh以请求改进。

[Kawa Kawamura提供了您可能感兴趣的反向代理后面运行的NiFi的open a Jira和文档。

© www.soinside.com 2019 - 2024. All rights reserved.