๐ NiFi TLS & Admin Access Setup (with NGINX)
๐ NiFi TLS & Admin Access Setup (with NGINX)
This guide documents how to configure TLS and certificate-based admin access for Apache NiFi behind NGINX. For background on how certificates are generated, see Certificates and Root CA.
๐ Folder Structure
security/certificates
โโโ elastic
โโโ nifi
โ โโโ nifi-keystore.jks
โ โโโ nifi-truststore.jks
โ โโโ nifi.crt
โ โโโ nifi.csr
โ โโโ nifi.key
โ โโโ nifi.p12
โ โโโ nifi.pem
โโโ root
โโโ root-ca-keystore.jks
โโโ root-ca-truststore.jks
โโโ root-ca.crt
โโโ root-ca.csr
โโโ root-ca.key
โโโ root-ca.p12
โโโ root-ca.pem
โโโ root-ca.srl
For securing Apache NiFi endpoints with certificates, see the official documentation.
Before starting the NiFi container:
- (optional if already done) run
create_root_ca_cert.shto generate root CA certs used across services. - set
nifi.sensitive.props.keyto a stable value (minimum 12 characters).
Example (nifi/conf/nifi.properties):
nifi.security.keystorePasswd=example-keystore-password
nifi.security.keyPasswd=example-key-password
nifi.security.truststore=./conf/truststore.jks
nifi.security.truststoreType=jks
nifi.security.truststorePasswd=example-truststore-password
Setting up access via user account (single user credentials)
Default:
username: admin
password: cogstackNiFi
login-identity-providers.xmlinnifi/conf/stores the account settings.- to generate credentials inside the container:
/opt/nifi/nifi-current/bin/nifi.sh set-single-user-credentials USERNAME PASSWORD
- alternatively:
- set credentials in
security/env/users_nifi.env - stop NiFi (
docker stop cogstack-nifi) - run
bash security/scripts/nifi_init_create_user_auth.sh
URL: https://localhost:8443/nifi/login
nifi-nginx
NGINX provides secure reverse-proxy access to NiFi at:
Reference: services/nginx/config/nginx.conf.template.
๐ authorizers.xml initial admin identity
Ensure your certificate identity is present in NiFi authorizers.xml:
<property name="Initial Admin Identity">C=UK, ST=London, L=UK, O=cogstack, OU=cogstack, CN=cogstack</property>
If you use DN mapping (nifi.security.identity.mapping.pattern.dn), ensure the mapped identity matches the configured admin identity.
๐ nifi.properties proxy settings
nifi.web.proxy.host=localhost:8443,nginx.local:8443
nifi.web.proxy.context.path=/nifi
nifi.security.identity.mapping.pattern.dn=^.*?CN=(.*?)(,|$)
๐ NGINX reverse proxy example (NiFi)
server {
listen 8443 ssl;
server_name nginx.local;
ssl_certificate /certificates/nifi/nifi.pem;
ssl_certificate_key /certificates/nifi/nifi.key;
ssl_client_certificate /certificates/root/root-ca.pem;
ssl_trusted_certificate /certificates/root/root-ca.pem;
location / {
proxy_set_header Host nifi;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-ProxyHost $host;
proxy_set_header X-ProxyPort 8443;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-ProxyScheme $scheme;
proxy_pass https://nifi;
}
location /nifi {
proxy_set_header Host nifi;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-ProxyHost $host;
proxy_set_header X-ProxyPort 8443;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-ProxyScheme $scheme;
proxy_pass https://nifi;
}
location ^~ /nifi-api/ {
proxy_set_header Host nifi;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-ProxyHost $host;
proxy_set_header X-ProxyPort 8443;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-ProxyScheme $scheme;
proxy_pass https://nifi/nifi-api/;
}
}
โ Final checklist
- [x] Certificate CN matches the NiFi admin identity
- [x] NGINX uses the expected certificates and root CA
- [x]
nifi.web.proxy.*settings match exposed URL and context - [x] Clear cookies if browser UI shows
Anonymous
๐งช Test connectivity
curl -vk --cert ./nifi.pem --key ./nifi.key https://localhost:8443/nifi-api/flow/about
๐ Troubleshooting
- Verify
Initial Admin Identityinauthorizers.xmlmatches the certificate identity. - Recreate
authorizations.xmlif permissions are stuck. - Restart NiFi after configuration updates.
Maintained by: admin@cogstack.org