在一个 NGINX 反向代理后面运行多个 NIFI 实例

在一个 NGINX 反向代理后面运行多个 NIFI 实例

我在不同的服务器上有 2 个 NIFI 实例,前面有 1 个 NGINX 反向代理。

它应该是这样的:

NGINX Reverse proxy > proxy.lan/nifi1 goes to the NIFI 1 instance on nifi1.lan
NGINX Reverse proxy > proxy.lan/nifi2 goes to the NIFI 2 instance on nifi2.lan

NGINX 反向代理在 192.168.1.114:80 上运行 NIFI 在 192.168.1.153:8080 上运行

我的配置文件nginx.conf:

server {
listen 80
server_name 192.168.1.114;

location /nifi1 {
proxy_set_header X-ProxyScheme "http";
proxy_set_header X-ProxyHost "192.168.1.114";
proxy_set_header X-ProxyPort "80";
proxy_set_header X-ProxyContextPath "/nifi1";
proxy_pass http://192.168.1.153:8080;
}
}

这是我的 NIFI nifi.properties 文件:

nifi.web.proxy.content.path=/nifi1
nifi.web.proxy.host=192.168.1.114:80

访问时http://192.168.1.114/nifi1,我会收到消息“您是指 /nifi 吗?”但页面看起来不对。它缺少页面样式。

5 秒后我被重定向到http://192.168.1.114/nifi1/nifi并且再次出现相同的消息“您是指/nifi 吗”,没有任何样式。

它只是不断地重定向,重试http://192.168.1.114/nifi/nifi1

要么是我缺少 NGINX 中的配置并且它没有传递 NIFI 所寻找的内容,要么 NIFI 无法处理我来自 NGINX 的请求并且它处于重定向循环中。

当直接转到http://192.168.1.153:8080/nifi,我可以正常获取该页面。

解决了!感谢一些 Linux 爱好者!

server {
listen 80
server_name 192.168.1.114;

location /nifi1/ {
proxy_set_header X-ProxyScheme "http";
proxy_set_header X-ProxyHost "192.168.1.114";
proxy_set_header X-ProxyPort "80";
proxy_set_header X-ProxyContextPath "/nifi1";
proxy_pass http://192.168.1.153:8080/;
}
}

相关内容