Docker 和 Nginx 中的 Apache NiFi

Apache NiFi in Docker and Nginx

我正在尝试在 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; 设置解决了将模板上传到服务的问题。

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

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

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

我在日志中看不到任何有用的信息。有一次出现了不使用HTTPS的错误,不过我觉得是没有关系的

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

我必须在我的 Nginx 配置文件中设置 proxy_set_header X-ProxyHost,它的效果非常好。我用的是我服务器的public IP,以后可能会换成域名。

这个问题的主要问题是缺少日志:我检查了nifi和nginx的所有日志,没有什么有趣的。我还在想这是不是bug。