在Nginx后面运行apachenifi

在Nginx后面运行apachenifi,nginx,apache-nifi,nginx-reverse-proxy,Nginx,Apache Nifi,Nginx Reverse Proxy,我正在尝试使用nginx作为反向代理来连接nifi。 我正在使用以下流程: 本地计算机->http->NGINX->https->安全NiFi 以下是我的nifi.properties配置: nifi.web.https.host=localhost nifi.web.https.port=8443 nifi.web.https.network.interface.default= nifi.web.jetty.working.directory=./work/jetty nifi.we

我正在尝试使用nginx作为反向代理来连接nifi。 我正在使用以下流程: 本地计算机->http->NGINX->https->安全NiFi

以下是我的nifi.properties配置:

nifi.web.https.host=localhost
 nifi.web.https.port=8443
 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/
 nifi.web.proxy.host=localhost:8443
 nifi.remote.input.host=localhost
 nifi.remote.input.secure=true
 server {
         listen       81;
         server_name  localhost;
     location /nifi/ {

        proxy_ssl_certificate     C:/nifi-toolkit-1.7.1/target/nifi-cert.pem;
        proxy_ssl_certificate_key C:/nifi-toolkit-1.7.1/target/nifi-key.key;
        proxy_ssl_server_name on;

        proxy_pass https://localhost:8443;
        proxy_set_header X-ProxyScheme "https";
        proxy_set_header X-ProxyHost $http_host;
        proxy_set_header X-ProxyPort 8443;
        proxy_set_header X-ProxyContextPath "";
        root   html;
        index  index.html index.htm;
    }

    location /nifi-api/{

        proxy_ssl_certificate     C:/nifi-toolkit-1.7.1/target/nifi-cert.pem;
        proxy_ssl_certificate_key C:/nifi-toolkit-1.7.1/target/nifi-key.key;
        proxy_ssl_server_name on;

        proxy_set_header X-ProxyScheme "https";
        proxy_set_header X-ProxyHost $http_host;
        proxy_set_header X-ProxyPort 443;
        proxy_set_header X-ProxyContextPath "";
        proxy_pass https://localhost:8443/nifi-api/;
 }
}
以下是我的nginx配置:

nifi.web.https.host=localhost
 nifi.web.https.port=8443
 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/
 nifi.web.proxy.host=localhost:8443
 nifi.remote.input.host=localhost
 nifi.remote.input.secure=true
 server {
         listen       81;
         server_name  localhost;
     location /nifi/ {

        proxy_ssl_certificate     C:/nifi-toolkit-1.7.1/target/nifi-cert.pem;
        proxy_ssl_certificate_key C:/nifi-toolkit-1.7.1/target/nifi-key.key;
        proxy_ssl_server_name on;

        proxy_pass https://localhost:8443;
        proxy_set_header X-ProxyScheme "https";
        proxy_set_header X-ProxyHost $http_host;
        proxy_set_header X-ProxyPort 8443;
        proxy_set_header X-ProxyContextPath "";
        root   html;
        index  index.html index.htm;
    }

    location /nifi-api/{

        proxy_ssl_certificate     C:/nifi-toolkit-1.7.1/target/nifi-cert.pem;
        proxy_ssl_certificate_key C:/nifi-toolkit-1.7.1/target/nifi-key.key;
        proxy_ssl_server_name on;

        proxy_set_header X-ProxyScheme "https";
        proxy_set_header X-ProxyHost $http_host;
        proxy_set_header X-ProxyPort 443;
        proxy_set_header X-ProxyContextPath "";
        proxy_pass https://localhost:8443/nifi-api/;
 }
}
当我尝试通过nginx访问nifi时,我在error.logs中得到以下错误:

2018/09/25 15:41:55 [error] 100964#77892: *27 upstream timed out (10060: A `connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "POST /nifi-api/access/oidc/exchange HTTP/1.1", upstream: "https://[::1]:8443/nifi-api/access/oidc/exchange", host: "localhost:81", referrer: "http://localhost:81/nifi/"`
以下是我点击url时在浏览器中遇到的错误:

是否有我缺少的任何配置设置。任何帮助都将不胜感激


提前感谢。

问题是nifi.web.proxy.context.path设置不正确

检查文档:

NiFi将只接受具有X-ProxyContextPath或 X-Forwarded-Context标头(如果值在 nifi.properties中的nifi.web.proxy.context.path属性。此属性 接受以逗号分隔的预期值列表。如果 传入请求具有X-ProxyContextPath或X-Forwarded-Context 白名单中不存在的标题值,即“意外” “发生错误”页面将显示,并将写入错误 nifi-app.log


正如echo所指出的,您的X-ProxyContextPath应该与您的位置相同,也应该与nifi.properties中的nifi.web.proxy.context.path=相同

在尝试在混合中引入SSL之前,我喜欢使用一个简单的HTTP身份验证来运行

客户端>http请求>NGINX反向代理>http请求>NIFI

在这种情况下,您的NIFI配置文件“NIFI.properties”应该如下所示:

 nifi.web.https.host=
 nifi.web.https.port=
 nifi.web.proxy.context.path=/
 nifi.web.proxy.host=localhost:80
 nifi.remote.input.host=localhost
 nifi.remote.input.secure=false
重新启动NIFI

注意上下文路径是/only,因此这是根目录下的所有内容

对于NGINX

server {
         listen       80;
         server_name  localhost;
     location / {

        proxy_pass https://YOUR_NIFI_INSTANCE:8080;
        proxy_set_header X-ProxyScheme "http";
        proxy_set_header X-ProxyHost localhost;
        proxy_set_header X-ProxyPort 80;
        proxy_set_header X-ProxyContextPath "/";
    }
}

使用NIFI框的url更新您的NIFI实例。

您可以不通过代理访问NIFI吗?也就是说,当您尝试访问
https://localhost:8443/nifi
并提供客户端证书?您好@kevdoran,很抱歉这么晚才回复。是的,我可以访问上述网址没有通过nifi。它工作正常。当我试图通过nginx访问nifi时,问题就出现了。Http在nginx中被阻止。当我尝试访问任何处理器时,我得到以下错误jQuery.min.js:4混合内容:“”处的页面是通过HTTPS加载的,但请求了不安全的XMLHttpRequest端点“”。此请求已被阻止;内容必须通过HTTPS提供。