【问题标题】:Apache NiFi in Docker and NginxDocker 和 Nginx 中的 Apache NiFi
【发布时间】:2020-06-29 19:45:35
【问题描述】:

我正在尝试在 EC2 实例上的 Docker 容器中部署 Apache NiFi。目前只有 2 个端口(80 和 443)开放,我无权更改它。

我已经成功启动 NiFi:

sudo docker run --name nifi   -p 8080:8080   -d   apache/nifi:latest

这是我的 nginx 配置:

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
    worker_connections 1024;
}
http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;
    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;
    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    include /etc/nginx/conf.d/*.conf;
    upstream nifi {
        server 0.0.0.0:8080;
        }
    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;

        location / {
                proxy_pass http://nifi;
                proxy_set_header Origin http://nifi;
        }
        error_page 404 /404.html;
            location = /40x.html {
        }
        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
}

目前 NiFi 工作,我可以通过实例的 IP 访问它。 proxy_set_header Origin http://nifi; 设置修复了将模板上传到服务的问题。

问题是我根本无法配置任何处理器。每次,当我单击“配置”时,我都会收到此错误:

Unable to communicate with NiFi
Please ensure the application is running and check the logs for any errors.

你能帮我解决这个问题吗?

我在日志中看不到任何有用的信息。一旦出现关于不使用HTTPS的错误,但我认为它不相关。

【问题讨论】:

    标签: docker nginx amazon-ec2 apache-nifi minify


    【解决方案1】:

    在摆弄 Docker、Nginx 和 NiFi 几天后,我发现了问题所在。 当我在浏览器中打开网络日志时,我注意到 Nifi 正在向 0.0.0.0 或 nifi(上游名称)发送请求。

    我必须在我的 Nginx 配置文件中设置proxy_set_header X-ProxyHost,它就像一个魅力。我用了我的服务器的公网IP,以后可能会切换到域名。

    这个问题的主要问题是缺少日志:我检查了 nifi 和 nginx 的所有日志,没有什么有趣的。我仍然想知道这是否是一个错误。

    【讨论】:

    • 这里有类似的问题兄弟。你为 X-ProxyHost 传递了什么 IP?似乎处理器配置窗口永远不会打开,我可以看到它在旋转并最终导致无法通信错误
    • 我认为我必须设置服务器的外部 IP 地址
    • 恐怕还是没帮到我。如果您对此 stackoverflow.com/questions/65922227/… 有任何想法,请告诉我。谢谢
    • @StrangerThinks 我无法访问我的工作设置自动取款机,但我想我明天可以给你发送答案
    • 已修复。我必须将它设置为“localhost”或环回 XProxy 才能正常工作。还相应地设置 x-proxy-context 路径
    猜你喜欢
    • 2019-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-26
    • 2017-08-31
    • 1970-01-01
    • 1970-01-01
    • 2020-07-02
    相关资源
    最近更新 更多