I'm running an Apache Nifi cluster on docker swarm using below configuration:
version: '3'
services:
zookeeper:
hostname: zookeeper
image: 'bitnami/zookeeper:latest'
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
nifi:
image: apache/nifi:latest
ports:
- 8080
environment:
- NIFI_WEB_HTTP_PORT=8080
- NIFI_CLUSTER_IS_NODE=true
- NIFI_CLUSTER_NODE_PROTOCOL_PORT=8082
- NIFI_ZK_CONNECT_STRING=zookeeper:2181
- NIFI_ELECTION_MAX_WAIT=1 min
This works fine and I can easily scale up the number of Nifi instances.
However, when trying to access the Nifi UI via the published port, it doesn't seem to work. I get a connection refused when trying to access it via any of the swarm nodes.
ID NAME MODE REPLICAS IMAGE PORTS
klp9kjm7jwdy nifi replicated 3/3 apache/nifi:latest *:30003->8080/tcp
qa3rf9pi6uyw zookeeper replicated 1/1 bitnami/zookeeper:latest
The problem seems to be related to the fact that Nifi is binding to the hostname for the host it runs on. Causing it to be only available inside the swarm network by using it's container id.
This does work from within any container inside the swarm network, but not via the published port.
I also tried configuring NIFI_WEB_HTTP_HOST=0.0.0.0 to make sure Nifi binds to all network interfaces, but that breaks communication between the instances in the cluster.
How should I configure Nifi/Docker swarm for being able to properly access Nifi's UI through the swarm routing mesh network?