Aleks Kuznetsov
Aleks Kuznetsov

Reputation: 570

Apache NiFi in Docker and Nginx

I'm trying to deploy Apache NiFi in a Docker container on EC2 Instance. Only 2 ports (80 and 443) are open at the moment and I don't have rights to change it.

I've managed to start NiFi:

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

Here is my nginx config:

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 {
        }
    }
}

At the moment NiFi works and I can access it via IP of the instance. proxy_set_header Origin http://nifi; setting fixed a problem with uploading templates to the service.

The problem is that I can't configure any processor at all. Every time, when I click on "configure" I get this error:

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

enter image description here

Can you please help me to fix this issue?

I can't see anything useful in the logs. Once an error about not using HTTPS has appeared, but I think it's not related.

Upvotes: 2

Views: 2033

Answers (1)

Aleks Kuznetsov
Aleks Kuznetsov

Reputation: 570

After a few days of fiddling with Docker, Nginx and NiFi, I've found the issue. When I've opened network logs in a browser, I've noticed that Nifi was sending a request to 0.0.0.0 or nifi (the name of upstream).

enter image description here

I had to set proxy_set_header X-ProxyHost in my Nginx config file and it worked like a charm. I used public IP of my server, maybe I'll switch to domain name later.

The main problem with this issue was in the lack of logs: I've checked all logs of nifi and nginx and there was nothing interesting. I'm still wondering if this is a bug or not.

Upvotes: 2

Related Questions