H__D  

  本章介绍NIFI组件的使用。

  主要有:Nginx反向代理NIFI,配置SSLContextService

Nginx反向代理NIFI

  使用nginx反向代理NIFI配置如下

 1 upstream nifi_server {    
 2     ip_hash;
 3     server 127.0.0.1:18002;
 4 }
 5                                                                                                                                    
 6 server {
 7     listen       80;
 8     server_name  nifi.example.com;    
 9     charset utf-8;
10                                                                                                                                        
11     location / {
12         proxy_pass      http://nifi_server;
13 
14         proxy_set_header Host $host;
15         proxy_set_header X-Real-IP $remote_addr;
16         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
17         proxy_set_header X-ProxyScheme http;
18         proxy_set_header X-ProxyHost nifi.example.com
19         proxy_set_header X-ProxyPort 80;           
20         proxy_set_header X-ProxyContextPath /;
21     }
22 }

 

配置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
    • Truststore类型:JKS
    • Truststore密码:如果您使用的是默认Java密钥库,则默认密码为"changeit"

  案例

    GetHTTP

    

    StandardSSLContextService

    

  模版

  1 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  2 <template encoding-version="1.2">
  3     <description></description>
  4     <groupId>620351d1-0168-1000-78a0-bf68b5b23177</groupId>
  5     <name>Https-Demo</name>
  6     <snippet>
  7         <connections>
  8             <id>c27e6613-7e35-3d9c-0000-000000000000</id>
  9             <parentGroupId>25bb3a09-a84a-3df9-0000-000000000000</parentGroupId>
 10             <backPressureDataSizeThreshold>1 GB</backPressureDataSizeThreshold>
 11             <backPressureObjectThreshold>10000</backPressureObjectThreshold>
 12             <destination>
 13                 <groupId>25bb3a09-a84a-3df9-0000-000000000000</groupId>
 14                 <id>a557eeeb-009b-316d-0000-000000000000</id>
 15                 <type>PROCESSOR</type>
 16             </destination>
 17             <flowFileExpiration>0 sec</flowFileExpiration>
 18             <labelIndex>1</labelIndex>
 19             <loadBalanceCompression>DO_NOT_COMPRESS</loadBalanceCompression>
 20             <loadBalancePartitionAttribute></loadBalancePartitionAttribute>
 21             <loadBalanceStatus>LOAD_BALANCE_NOT_CONFIGURED</loadBalanceStatus>
 22             <loadBalanceStrategy>DO_NOT_LOAD_BALANCE</loadBalanceStrategy>
 23             <name></name>
 24             <selectedRelationships>success</selectedRelationships>
 25             <source>
 26                 <groupId>25bb3a09-a84a-3df9-0000-000000000000</groupId>
 27                 <id>e132b9d2-4ae9-3941-0000-000000000000</id>
 28                 <type>PROCESSOR</type>
 29             </source>
 30             <zIndex>0</zIndex>
 31         </connections>
 32         <controllerServices>
 33             <id>43bd3854-302f-30dd-0000-000000000000</id>
 34             <parentGroupId>25bb3a09-a84a-3df9-0000-000000000000</parentGroupId>
 35             <bundle>
 36                 <artifact>nifi-ssl-context-service-nar</artifact>
 37                 <group>org.apache.nifi</group>
 38                 <version>1.8.0</version>
 39             </bundle>
 40             <comments></comments>
 41             <descriptors>
 42                 <entry>
 43                     <key>Keystore Filename</key>
 44                     <value>
 45                         <name>Keystore Filename</name>
 46                     </value>
 47                 </entry>
 48                 <entry>
 49                     <key>Keystore Password</key>
 50                     <value>
 51                         <name>Keystore Password</name>
 52                     </value>
 53                 </entry>
 54                 <entry>
 55                     <key>key-password</key>
 56                     <value>
 57                         <name>key-password</name>
 58                     </value>
 59                 </entry>
 60                 <entry>
 61                     <key>Keystore Type</key>
 62                     <value>
 63                         <name>Keystore Type</name>
 64                     </value>
 65                 </entry>
 66                 <entry>
 67                     <key>Truststore Filename</key>
 68                     <value>
 69                         <name>Truststore Filename</name>
 70                     </value>
 71                 </entry>
 72                 <entry>
 73                     <key>Truststore Password</key>
 74                     <value>
 75                         <name>Truststore Password</name>
 76                     </value>
 77                 </entry>
 78                 <entry>
 79                     <key>Truststore Type</key>
 80                     <value>
 81                         <name>Truststore Type</name>
 82                     </value>
 83                 </entry>
 84                 <entry>
 85                     <key>SSL Protocol</key>
 86                     <value>
 87                         <name>SSL Protocol</name>
 88                     </value>
 89                 </entry>
 90             </descriptors>
 91             <name>StandardSSLContextService</name>
 92             <persistsState>false</persistsState>
 93             <properties>
 94                 <entry>
 95                     <key>Keystore Filename</key>
 96                 </entry>
 97                 <entry>
 98                     <key>Keystore Password</key>
 99                 </entry>
100                 <entry>
101                     <key>key-password</key>
102                 </entry>
103                 <entry>
104                     <key>Keystore Type</key>
105                 </entry>
106                 <entry>
107                     <key>Truststore Filename</key>
108                     <value>/data/soft/jdk1.8.0_181/jre/lib/security/cacerts</value>
109                 </entry>
110                 <entry>
111                     <key>Truststore Password</key>
112                 </entry>
113                 <entry>
114                     <key>Truststore Type</key>
115                     <value>JKS</value>
116                 </entry>
117                 <entry>
118                     <key>SSL Protocol</key>
119                 </entry>
120             </properties>
121             <state>ENABLED</state>
122             <type>org.apache.nifi.ssl.StandardSSLContextService</type>
123         </controllerServices>
124         <processors>
125             <id>a557eeeb-009b-316d-0000-000000000000</id>
126             <parentGroupId>25bb3a09-a84a-3df9-0000-000000000000</parentGroupId>
127             <position>
128                 <x>0.0</x>
129                 <y>250.0</y>
130             </position>
131             <bundle>
132                 <artifact>nifi-standard-nar</artifact>
133                 <group>org.apache.nifi</group>
134                 <version>1.8.0</version>
135             </bundle>
136             <config>
137                 <bulletinLevel>WARN</bulletinLevel>
138                 <comments></comments>
139                 <concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount>
140                 <descriptors>
141                     <entry>
142                         <key>Regular Expression</key>
143                         <value>
144                             <name>Regular Expression</name>
145                         </value>
146                     </entry>
147                     <entry>
148                         <key>Replacement Value</key>
149                         <value>
150                             <name>Replacement Value</name>
151                         </value>
152                     </entry>
153                     <entry>
154                         <key>Character Set</key>
155                         <value>
156                             <name>Character Set</name>
157                         </value>
158                     </entry>
159                     <entry>
160                         <key>Maximum Buffer Size</key>
161                         <value>
162                             <name>Maximum Buffer Size</name>
163                         </value>
164                     </entry>
165                     <entry>
166                         <key>Replacement Strategy</key>
167                         <value>
168                             <name>Replacement Strategy</name>
169                         </value>
170                     </entry>
171                     <entry>
172                         <key>Evaluation Mode</key>
173                         <value>
174                             <name>Evaluation Mode</name>
175                         </value>
176                     </entry>
177                 </descriptors>
178                 <executionNode>ALL</executionNode>
179                 <lossTolerant>false</lossTolerant>
180                 <penaltyDuration>30 sec</penaltyDuration>
181                 <properties>
182                     <entry>
183                         <key>Regular Expression</key>
184                         <value>(?s)(^.*$)</value>
185                     </entry>
186                     <entry>
187                         <key>Replacement Value</key>
188                         <value>$1</value>
189                     </entry>
190                     <entry>
191                         <key>Character Set</key>
192                         <value>UTF-8</value>
193                     </entry>
194                     <entry>
195                         <key>Maximum Buffer Size</key>
196                         <value>1 MB</value>
197                     </entry>
198                     <entry>
199                         <key>Replacement Strategy</key>
200                         <value>Regex Replace</value>
201                     </entry>
202                     <entry>
203                         <key>Evaluation Mode</key>
204                         <value>Entire text</value>
205                     </entry>
206                 </properties>
207                 <runDurationMillis>0</runDurationMillis>
208                 <schedulingPeriod>0 sec</schedulingPeriod>
209                 <schedulingStrategy>TIMER_DRIVEN</schedulingStrategy>
210                 <yieldDuration>1 sec</yieldDuration>
211             </config>
212             <executionNodeRestricted>false</executionNodeRestricted>
213             <name>ReplaceText</name>
214             <relationships>
215                 <autoTerminate>false</autoTerminate>
216                 <name>failure</name>
217             </relationships>
218             <relationships>
219                 <autoTerminate>false</autoTerminate>
220                 <name>success</name>
221             </relationships>
222             <state>STOPPED</state>
223             <style/>
224             <type>org.apache.nifi.processors.standard.ReplaceText</type>
225         </processors>
226         <processors>
227             <id>e132b9d2-4ae9-3941-0000-000000000000</id>
228             <parentGroupId>25bb3a09-a84a-3df9-0000-000000000000</parentGroupId>
229             <position>
230                 <x>0.0</x>
231                 <y>0.0</y>
232             </position>
233             <bundle>
234                 <artifact>nifi-standard-nar</artifact>
235                 <group>org.apache.nifi</group>
236                 <version>1.8.0</version>
237             </bundle>
238             <config>
239                 <bulletinLevel>WARN</bulletinLevel>
240                 <comments></comments>
241                 <concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount>
242                 <descriptors>
243                     <entry>
244                         <key>URL</key>
245                         <value>
246                             <name>URL</name>
247                         </value>
248                     </entry>
249                     <entry>
250                         <key>Filename</key>
251                         <value>
252                             <name>Filename</name>
253                         </value>
254                     </entry>
255                     <entry>
256                         <key>SSL Context Service</key>
257                         <value>
258                             <identifiesControllerService>org.apache.nifi.ssl.SSLContextService</identifiesControllerService>
259                             <name>SSL Context Service</name>
260                         </value>
261                     </entry>
262                     <entry>
263                         <key>Username</key>
264                         <value>
265                             <name>Username</name>
266                         </value>
267                     </entry>
268                     <entry>
269                         <key>Password</key>
270                         <value>
271                             <name>Password</name>
272                         </value>
273                     </entry>
274                     <entry>
275                         <key>Connection Timeout</key>
276                         <value>
277                             <name>Connection Timeout</name>
278                         </value>
279                     </entry>
280                     <entry>
281                         <key>Data Timeout</key>
282                         <value>
283                             <name>Data Timeout</name>
284                         </value>
285                     </entry>
286                     <entry>
287                         <key>User Agent</key>
288                         <value>
289                             <name>User Agent</name>
290                         </value>
291                     </entry>
292                     <entry>
293                         <key>Accept Content-Type</key>
294                         <value>
295                             <name>Accept Content-Type</name>
296                         </value>
297                     </entry>
298                     <entry>
299                         <key>Follow Redirects</key>
300                         <value>
301                             <name>Follow Redirects</name>
302                         </value>
303                     </entry>
304                     <entry>
305                         <key>redirect-cookie-policy</key>
306                         <value>
307                             <name>redirect-cookie-policy</name>
308                         </value>
309                     </entry>
310                     <entry>
311                         <key>proxy-configuration-service</key>
312                         <value>
313                             <identifiesControllerService>org.apache.nifi.proxy.ProxyConfigurationService</identifiesControllerService>
314                             <name>proxy-configuration-service</name>
315                         </value>
316                     </entry>
317                     <entry>
318                         <key>Proxy Host</key>
319                         <value>
320                             <name>Proxy Host</name>
321                         </value>
322                     </entry>
323                     <entry>
324                         <key>Proxy Port</key>
325                         <value>
326                             <name>Proxy Port</name>
327                         </value>
328                     </entry>
329                 </descriptors>
330                 <executionNode>ALL</executionNode>
331                 <lossTolerant>false</lossTolerant>
332                 <penaltyDuration>30 sec</penaltyDuration>
333                 <properties>
334                     <entry>
335                         <key>URL</key>
336                         <value>https://www.baidu.com</value>
337                     </entry>
338                     <entry>
339                         <key>Filename</key>
340                         <value>index.html</value>
341                     </entry>
342                     <entry>
343                         <key>SSL Context Service</key>
344                         <value>43bd3854-302f-30dd-0000-000000000000</value>
345                     </entry>
346                     <entry>
347                         <key>Username</key>
348                     </entry>
349                     <entry>
350                         <key>Password</key>
351                     </entry>
352                     <entry>
353                         <key>Connection Timeout</key>
354                         <value>30 sec</value>
355                     </entry>
356                     <entry>
357                         <key>Data Timeout</key>
358                         <value>30 sec</value>
359                     </entry>
360                     <entry>
361                         <key>User Agent</key>
362                     </entry>
363                     <entry>
364                         <key>Accept Content-Type</key>
365                     </entry>
366                     <entry>
367                         <key>Follow Redirects</key>
368                         <value>false</value>
369                     </entry>
370                     <entry>
371                         <key>redirect-cookie-policy</key>
372                         <value>default</value>
373                     </entry>
374                     <entry>
375                         <key>proxy-configuration-service</key>
376                     </entry>
377                     <entry>
378                         <key>Proxy Host</key>
379                     </entry>
380                     <entry>
381                         <key>Proxy Port</key>
382                     </entry>
383                 </properties>
384                 <runDurationMillis>0</runDurationMillis>
385                 <schedulingPeriod>10 sec</schedulingPeriod>
386                 <schedulingStrategy>TIMER_DRIVEN</schedulingStrategy>
387                 <yieldDuration>1 sec</yieldDuration>
388             </config>
389             <executionNodeRestricted>false</executionNodeRestricted>
390             <name>GetHTTP</name>
391             <relationships>
392                 <autoTerminate>false</autoTerminate>
393                 <name>success</name>
394             </relationships>
395             <state>STOPPED</state>
396             <style/>
397             <type>org.apache.nifi.processors.standard.GetHTTP</type>
398         </processors>
399     </snippet>
400     <timestamp>01/19/2019 02:06:56 CST</timestamp>
401 </template>
View Code

 

    

  

 

posted on 2019-01-19 02:08  H__D  阅读(1771)  评论(0编辑  收藏  举报