本章介绍NIFI组件的使用。
主要有:Nginx反向代理NIFI,配置SSLContextService
Nginx反向代理NIFI
使用nginx反向代理NIFI配置如下
upstream nifi_server {
ip_hash;
server 127.0.0.1:18002;
} server {
listen 80;
server_name nifi.example.com;
charset utf-8; location / {
proxy_pass http://nifi_server; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-ProxyScheme http;
proxy_set_header X-ProxyHost nifi.example.com
proxy_set_header X-ProxyPort 80;
proxy_set_header X-ProxyContextPath /;
}
}
配置SSLContextService
SSLContextService,可以用来发送https请求
SSL Context Service实例配置信任库属性:
-
Truststore文件名:Java安装中的cacerts文件
- 如果在您的系统上设置了$JAVA_HOME,它应该有助于指向正确的方向。如果不是,cacerts的位置根据环境而变化,但是对于它们各自的OS大致如下
- OS X: /Library/Java/JavaVirtualMachines/jdk<version>.jdk/Contents/Home/jre/lib/security/cacerts
- Windows:C:\Program Files\Java\jdk <version>\jre\lib\security\ cacerts
- Linux:/usr/local/java-<version>/jre/lib/security/cacerts
- 如果在您的系统上设置了$JAVA_HOME,它应该有助于指向正确的方向。如果不是,cacerts的位置根据环境而变化,但是对于它们各自的OS大致如下
- Truststore类型:JKS
- Truststore密码:如果您使用的是默认Java密钥库,则默认密码为"changeit"
案例
GetHTTP
StandardSSLContextService
模版
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<template encoding-version="1.2">
<description></description>
<groupId>620351d1-0168-1000-78a0-bf68b5b23177</groupId>
<name>Https-Demo</name>
<snippet>
<connections>
<id>c27e6613-7e35-3d9c-0000-000000000000</id>
<parentGroupId>25bb3a09-a84a-3df9-0000-000000000000</parentGroupId>
<backPressureDataSizeThreshold>1 GB</backPressureDataSizeThreshold>
<backPressureObjectThreshold>10000</backPressureObjectThreshold>
<destination>
<groupId>25bb3a09-a84a-3df9-0000-000000000000</groupId>
<id>a557eeeb-009b-316d-0000-000000000000</id>
<type>PROCESSOR</type>
</destination>
<flowFileExpiration>0 sec</flowFileExpiration>
<labelIndex>1</labelIndex>
<loadBalanceCompression>DO_NOT_COMPRESS</loadBalanceCompression>
<loadBalancePartitionAttribute></loadBalancePartitionAttribute>
<loadBalanceStatus>LOAD_BALANCE_NOT_CONFIGURED</loadBalanceStatus>
<loadBalanceStrategy>DO_NOT_LOAD_BALANCE</loadBalanceStrategy>
<name></name>
<selectedRelationships>success</selectedRelationships>
<source>
<groupId>25bb3a09-a84a-3df9-0000-000000000000</groupId>
<id>e132b9d2-4ae9-3941-0000-000000000000</id>
<type>PROCESSOR</type>
</source>
<zIndex>0</zIndex>
</connections>
<controllerServices>
<id>43bd3854-302f-30dd-0000-000000000000</id>
<parentGroupId>25bb3a09-a84a-3df9-0000-000000000000</parentGroupId>
<bundle>
<artifact>nifi-ssl-context-service-nar</artifact>
<group>org.apache.nifi</group>
<version>1.8.0</version>
</bundle>
<comments></comments>
<descriptors>
<entry>
<key>Keystore Filename</key>
<value>
<name>Keystore Filename</name>
</value>
</entry>
<entry>
<key>Keystore Password</key>
<value>
<name>Keystore Password</name>
</value>
</entry>
<entry>
<key>key-password</key>
<value>
<name>key-password</name>
</value>
</entry>
<entry>
<key>Keystore Type</key>
<value>
<name>Keystore Type</name>
</value>
</entry>
<entry>
<key>Truststore Filename</key>
<value>
<name>Truststore Filename</name>
</value>
</entry>
<entry>
<key>Truststore Password</key>
<value>
<name>Truststore Password</name>
</value>
</entry>
<entry>
<key>Truststore Type</key>
<value>
<name>Truststore Type</name>
</value>
</entry>
<entry>
<key>SSL Protocol</key>
<value>
<name>SSL Protocol</name>
</value>
</entry>
</descriptors>
<name>StandardSSLContextService</name>
<persistsState>false</persistsState>
<properties>
<entry>
<key>Keystore Filename</key>
</entry>
<entry>
<key>Keystore Password</key>
</entry>
<entry>
<key>key-password</key>
</entry>
<entry>
<key>Keystore Type</key>
</entry>
<entry>
<key>Truststore Filename</key>
<value>/data/soft/jdk1.8.0_181/jre/lib/security/cacerts</value>
</entry>
<entry>
<key>Truststore Password</key>
</entry>
<entry>
<key>Truststore Type</key>
<value>JKS</value>
</entry>
<entry>
<key>SSL Protocol</key>
</entry>
</properties>
<state>ENABLED</state>
<type>org.apache.nifi.ssl.StandardSSLContextService</type>
</controllerServices>
<processors>
<id>a557eeeb-009b-316d-0000-000000000000</id>
<parentGroupId>25bb3a09-a84a-3df9-0000-000000000000</parentGroupId>
<position>
<x>0.0</x>
<y>250.0</y>
</position>
<bundle>
<artifact>nifi-standard-nar</artifact>
<group>org.apache.nifi</group>
<version>1.8.0</version>
</bundle>
<config>
<bulletinLevel>WARN</bulletinLevel>
<comments></comments>
<concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount>
<descriptors>
<entry>
<key>Regular Expression</key>
<value>
<name>Regular Expression</name>
</value>
</entry>
<entry>
<key>Replacement Value</key>
<value>
<name>Replacement Value</name>
</value>
</entry>
<entry>
<key>Character Set</key>
<value>
<name>Character Set</name>
</value>
</entry>
<entry>
<key>Maximum Buffer Size</key>
<value>
<name>Maximum Buffer Size</name>
</value>
</entry>
<entry>
<key>Replacement Strategy</key>
<value>
<name>Replacement Strategy</name>
</value>
</entry>
<entry>
<key>Evaluation Mode</key>
<value>
<name>Evaluation Mode</name>
</value>
</entry>
</descriptors>
<executionNode>ALL</executionNode>
<lossTolerant>false</lossTolerant>
<penaltyDuration>30 sec</penaltyDuration>
<properties>
<entry>
<key>Regular Expression</key>
<value>(?s)(^.*$)</value>
</entry>
<entry>
<key>Replacement Value</key>
<value>$1</value>
</entry>
<entry>
<key>Character Set</key>
<value>UTF-8</value>
</entry>
<entry>
<key>Maximum Buffer Size</key>
<value>1 MB</value>
</entry>
<entry>
<key>Replacement Strategy</key>
<value>Regex Replace</value>
</entry>
<entry>
<key>Evaluation Mode</key>
<value>Entire text</value>
</entry>
</properties>
<runDurationMillis>0</runDurationMillis>
<schedulingPeriod>0 sec</schedulingPeriod>
<schedulingStrategy>TIMER_DRIVEN</schedulingStrategy>
<yieldDuration>1 sec</yieldDuration>
</config>
<executionNodeRestricted>false</executionNodeRestricted>
<name>ReplaceText</name>
<relationships>
<autoTerminate>false</autoTerminate>
<name>failure</name>
</relationships>
<relationships>
<autoTerminate>false</autoTerminate>
<name>success</name>
</relationships>
<state>STOPPED</state>
<style/>
<type>org.apache.nifi.processors.standard.ReplaceText</type>
</processors>
<processors>
<id>e132b9d2-4ae9-3941-0000-000000000000</id>
<parentGroupId>25bb3a09-a84a-3df9-0000-000000000000</parentGroupId>
<position>
<x>0.0</x>
<y>0.0</y>
</position>
<bundle>
<artifact>nifi-standard-nar</artifact>
<group>org.apache.nifi</group>
<version>1.8.0</version>
</bundle>
<config>
<bulletinLevel>WARN</bulletinLevel>
<comments></comments>
<concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount>
<descriptors>
<entry>
<key>URL</key>
<value>
<name>URL</name>
</value>
</entry>
<entry>
<key>Filename</key>
<value>
<name>Filename</name>
</value>
</entry>
<entry>
<key>SSL Context Service</key>
<value>
<identifiesControllerService>org.apache.nifi.ssl.SSLContextService</identifiesControllerService>
<name>SSL Context Service</name>
</value>
</entry>
<entry>
<key>Username</key>
<value>
<name>Username</name>
</value>
</entry>
<entry>
<key>Password</key>
<value>
<name>Password</name>
</value>
</entry>
<entry>
<key>Connection Timeout</key>
<value>
<name>Connection Timeout</name>
</value>
</entry>
<entry>
<key>Data Timeout</key>
<value>
<name>Data Timeout</name>
</value>
</entry>
<entry>
<key>User Agent</key>
<value>
<name>User Agent</name>
</value>
</entry>
<entry>
<key>Accept Content-Type</key>
<value>
<name>Accept Content-Type</name>
</value>
</entry>
<entry>
<key>Follow Redirects</key>
<value>
<name>Follow Redirects</name>
</value>
</entry>
<entry>
<key>redirect-cookie-policy</key>
<value>
<name>redirect-cookie-policy</name>
</value>
</entry>
<entry>
<key>proxy-configuration-service</key>
<value>
<identifiesControllerService>org.apache.nifi.proxy.ProxyConfigurationService</identifiesControllerService>
<name>proxy-configuration-service</name>
</value>
</entry>
<entry>
<key>Proxy Host</key>
<value>
<name>Proxy Host</name>
</value>
</entry>
<entry>
<key>Proxy Port</key>
<value>
<name>Proxy Port</name>
</value>
</entry>
</descriptors>
<executionNode>ALL</executionNode>
<lossTolerant>false</lossTolerant>
<penaltyDuration>30 sec</penaltyDuration>
<properties>
<entry>
<key>URL</key>
<value>https://www.baidu.com</value>
</entry>
<entry>
<key>Filename</key>
<value>index.html</value>
</entry>
<entry>
<key>SSL Context Service</key>
<value>43bd3854-302f-30dd-0000-000000000000</value>
</entry>
<entry>
<key>Username</key>
</entry>
<entry>
<key>Password</key>
</entry>
<entry>
<key>Connection Timeout</key>
<value>30 sec</value>
</entry>
<entry>
<key>Data Timeout</key>
<value>30 sec</value>
</entry>
<entry>
<key>User Agent</key>
</entry>
<entry>
<key>Accept Content-Type</key>
</entry>
<entry>
<key>Follow Redirects</key>
<value>false</value>
</entry>
<entry>
<key>redirect-cookie-policy</key>
<value>default</value>
</entry>
<entry>
<key>proxy-configuration-service</key>
</entry>
<entry>
<key>Proxy Host</key>
</entry>
<entry>
<key>Proxy Port</key>
</entry>
</properties>
<runDurationMillis>0</runDurationMillis>
<schedulingPeriod>10 sec</schedulingPeriod>
<schedulingStrategy>TIMER_DRIVEN</schedulingStrategy>
<yieldDuration>1 sec</yieldDuration>
</config>
<executionNodeRestricted>false</executionNodeRestricted>
<name>GetHTTP</name>
<relationships>
<autoTerminate>false</autoTerminate>
<name>success</name>
</relationships>
<state>STOPPED</state>
<style/>
<type>org.apache.nifi.processors.standard.GetHTTP</type>
</processors>
</snippet>
<timestamp>01/19/2019 02:06:56 CST</timestamp>
</template>