nginx - 在 Nginx 后面运行 Apache NiFi
问题描述
我正在尝试使用 nginx 作为反向代理来连接到 nifi。我正在使用以下流程:本地机器 -> http -> NGINX -> https -> Secure 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
下面是我的nginx配置:
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 时在浏览器中遇到的错误:http://localhost:81/nifi/
是否有任何我缺少的配置设置。任何帮助将不胜感激。
先感谢您。
解决方案
问题是 nifi.web.proxy.context.path 设置不正确。
检查文档:
如果值在 nifi.properties 的 nifi.web.proxy.context.path 属性中列入白名单,NiFi 将仅接受带有 X-ProxyContextPath 或 X-Forwarded-Context 标头的 HTTP 请求。此属性接受以逗号分隔的预期值列表。如果传入请求具有白名单中不存在的 X-ProxyContextPath 或 X-Forwarded-Context 标头值,将显示“发生意外错误”页面并将错误写入 nifi-app 。日志。
推荐阅读
- c - strcpy() 跳过数组元素
- python - 在python中搜索特定单词后将文本单词附加到文本文件中
- python - 将列表中的每个元素转换为键值对
- python - 使用张量流创建图像
- sql - 在数据库中保存图像名称或完整 URL 是最佳实践
- sql - 我需要通过一个 sql 查询来实现以下逻辑
- ruby-on-rails - 需要帮助才能从模型中获取 remote_ip
- javascript - 在 html 和 Javascript 中实现自定义表的标题?
- angular - 使用 ng2-dragula 在 mat-grid 中拖放 mat-card
- mysql - 使用 mySQL 从两个表中进行一次查询中的 SELECT 和 COUNT