0

I have 2 NIFI instance on differents servers with 1 NGINX reverse proxy in front.

It should go like this:

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 reverse proxy runs on 192.168.1.114:80 NIFI runs on 192.168.1.153:8080

My configuration file 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;
}
}

This is my NIFI nifi.properties file:

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

When accessing http://192.168.1.114/nifi1, I will get the message "Did you mean /nifi" but the page looks off. It's missing the styling of the page.

I get redirected after 5 secs to http://192.168.1.114/nifi1/nifi and the same message appears "Did you mean /nifi", again, without any styling.

And it just keeps redirecting over and over, retrying http://192.168.1.114/nifi/nifi1.

Either i'm missing a configuration in NGINX and it's not passing what NIFI is looking for, or NIFI can't process my request from NGINX and it's in a redirecting loop.

When going directly to http://192.168.1.153:8080/nifi, I can get the page just fine.

Solved! Thank you to some linux nerd!

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/;
}
}
  • It's quite possible, you can setup proxy rules based on the location of the request. Here's an example: http://nginx.org/en/docs/http/ngx_http_proxy_module.html - but realize that instead of: location / { } you could use: location /nifi1 { } to only have it proxy the url proxy/nifi1 – Some Linux Nerd Sep 23 '20 at 20:58
  • Thanks for replying! I'm still learning NGINX and NIFI at this point so bear with me. – B1naryC0DE Sep 23 '20 at 22:48
  • I've added more information in my original comment. – B1naryC0DE Sep 23 '20 at 23:54
  • You have to rewrite the url that's passed to the proxy, by default a reverse proxy sends the url that you send it, so you need to rewrite the url before sending it to proxy_pass. Here's an example of how to do that: https://serverfault.com/questions/379675/nginx-reverse-proxy-url-rewrite – Some Linux Nerd Sep 25 '20 at 02:45
  • I can't believe that worked! THANK YOU! – B1naryC0DE Sep 25 '20 at 03:25

0 Answers0