Debian Codegraph @

doc/modules/mod_redis.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>ProFTPD module mod_redis</title>
5 </head>
6
7 <body bgcolor=white>
8
9 <hr>
10 <center>
11 <h2><b>ProFTPD module <code>mod_redis</code></b></h2>
12 </center>
13 <hr><br>
14
15 <p>
16 The <code>mod_redis</code> module enables ProFTPD support for caching data in
17 <a href="https://redis.io">Redis</a> servers, using the
18 <a href="https://github.com/redis/hiredis">hiredis</a> client library.
19
20 <h2>Directives</h2>
21 <ul>
22 <li><a href="#RedisEngine">RedisEngine</a>
23 <li><a href="#RedisLog">RedisLog</a>
24 <li><a href="#RedisLogFormatExtra">RedisLogFormatExtra</a>
25 <li><a href="#RedisLogOnCommand">RedisLogOnCommand</a>
26 <li><a href="#RedisLogOnEvent">RedisLogOnEvent</a>
27 <li><a href="#RedisOptions">RedisOptions</a>
28 <li><a href="#RedisSentinel">RedisSentinel</a>
29 <li><a href="#RedisServer">RedisServer</a>
30 <li><a href="#RedisTimeouts">RedisTimeouts</a>
31 </ul>
32
33 <hr>
34 <h3><a name="RedisEngine">RedisEngine</a></h3>
35 <strong>Syntax:</strong> RedisEngine <em>on|off</em><br>
36 <strong>Default:</strong> RedisEngine off<br>
37 <strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code><br>
38 <strong>Module:</strong> mod_redis<br>
39 <strong>Compatibility:</strong> 1.3.6rc5 and later
40
41 <p>
42 The <code>RedisEngine</code> directive enables or disables the
43 <code>mod_redis</code> module, and thus the configuration of Redis support for
44 the <code>proftpd</code> daemon.
45
46 <p>
47 <hr>
48 <h3><a name="RedisLog">RedisLog</a></h3>
49 <strong>Syntax:</strong> RedisLog <em>path|"none"</em><br>
50 <strong>Default:</strong> None<br>
51 <strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code><br>
52 <strong>Module:</strong> mod_redis<br>
53 <strong>Compatibility:</strong> 1.3.6rc5 and later
54
55 <p>
56 The <code>RedisLog</code> directive is used to specify a log file for
57 <code>mod_redis</code>'s reporting on a per-server basis. The
58 <em>file</em> parameter given must be the full path to the file to use for
59 logging.
60
61 <p>
62 Note that this path must <b>not</b> be to a world-writable directory and,
63 unless <code>AllowLogSymlinks</code> is explicitly set to <em>on</em>
64 (generally a bad idea), the path must <b>not</b> be a symbolic link.
65
66 <p>
67 <hr>
68 <h3><a name="RedisLogFormatExtra">RedisLogFormatExtra</a></h3>
69 <strong>Syntax:</strong> RedisLogFormatExtra <em>format-name json-object</em><br>
70 <strong>Default:</strong> None<br>
71 <strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code>, <code>&lt;Anonymous&gt;</code>, <code>&lt;Directory&gt;</code><br>
72 <strong>Module:</strong> mod_redis<br>
73 <strong>Compatibility:</strong> 1.3.8rc1 and later
74
75 <p>
76 The <code>RedisLogFormatExtra</code> directive configures "extra" data to be
77 added to the JSON logging, performed by <code>RedisLogOnCommand</code> and
78 <code>RedisLogOnEvent</code>.
79
80 The <em>format-name</em> parameter indicates that the <em>json-object</em> extra
81 data should be added to that payload. This allows adding of custom JSON object
82 key/value pairs.
83
84 Example:
85 <pre>
86 LogFormat file-transfers "%h %l %u %t \"%r\" %s %b"
87
88 RedisLogOnCommand RETR,STOR file-transfers %m:ftpxfer:%u
89 RedisLogFormatExtra file-transfers {"custom_property1":"%m","custom_property2":"custom_value"}
90 </pre>
91
92 <p>
93 <hr>
94 <h3><a name="RedisLogOnCommand">RedisLogOnCommand</a></h3>
95 <strong>Syntax:</strong> RedisLogOnCommand <em>"none"|commands format-name [key]</em><br>
96 <strong>Default:</strong> None<br>
97 <strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code>, <code>&lt;Anonymous&gt;</code>, <code>&lt;Directory&gt;</code><br>
98 <strong>Module:</strong> mod_redis<br>
99 <strong>Compatibility:</strong> 1.3.6rc5 and later
100
101 <p>
102 The <code>RedisLogOnCommand</code> directive configures the use of Redis for
103 <em>logging</em>. Whenever one of the comma-separated list of <em>commands</em>
104 occurs, <code>mod_redis</code> will compose a JSON object, using the
105 <a href="mod_log.html#LogFormat"><code>LogFormat</code></a> named by
106 <em>format-name</em> as a <i>template</i> for the fields to include in the
107 JSON object. The JSON object of that event will then be appended to a list
108 stored in Redis, using <em>format-name</em> as the default key name. Multiple
109 <code>RedisLogOnCommand</code> directives can be used, for different log formats
110 for different events.
111
112 <p>
113 The optional <em>key</em> parameter, if present, specifies the value to use
114 as the Redis key. This <em>key</em> parameter supports all of the
115 <code>LogFormat</code> variables, thus you can use <i>e.g.</i>:
116 <pre>
117 RedisLogOnCommand RETR,STOR xferlog %m:ftpxfer:%u
118 </pre>
119
120 <p>
121 More on the use of Redis logging, including a table showing how
122 <code>LogFormat</code> variables are mapped to JSON object keys can be found
123 <a href="#Logging">here</a>.
124
125 <p>
126 Example:
127 <pre>
128 LogFormat file-transfers "%h %l %u %t \"%r\" %s %b"
129
130 # Only log to Redis for uploads in this directory
131 &lt;Directory /path/to/inbox&gt;
132 RedisLogOnCommand APPE,STOR,STOU file-transfers
133 &lt;/Directory&gt;
134
135 # Only log to Redis for downloads from this directory
136 &lt;Directory /path/to/pub&gt;
137 RedisLogOnCommand RETR file-transfers
138 &lt;/Directory&gt;
139
140 # ...but prevent Redis logging in this subdirectory
141 &lt;Directory /path/to/pub/subdir&gt;
142 RedisLogOnCommand none
143 &lt;/Directory&gt;
144 </pre>
145
146 <p>
147 <b>Note</b> that <code>RedisLogOnCommand</code> does <b>not</b> currently
148 support the logging <i>classes</i> that the <code>ExtendedLog</code> directive
149 supports.
150
151 <p>
152 <hr>
153 <h3><a name="RedisLogOnEvent">RedisLogOnEvent</a></h3>
154 <strong>Syntax:</strong> RedisLogOnEvent <em>"none"|events format-name [key]</em><br>
155 <strong>Default:</strong> None<br>
156 <strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code>, <code>&lt;Anonymous&gt;</code>, <code>&lt;Directory&gt;</code><br>
157 <strong>Module:</strong> mod_redis<br>
158 <strong>Compatibility:</strong> 1.3.7rc1 and later
159
160 <p>
161 The <code>RedisLogOnEvent</code> directive configures the use of Redis for
162 <em>logging</em>. Whenever one of the comma-separated list of <em>events</em>
163 occurs, <code>mod_redis</code> will compose a JSON object, using the
164 <a href="mod_log.html#LogFormat"><code>LogFormat</code></a> named by
165 <em>format-name</em> as a <i>template</i> for the fields to include in the
166 JSON object. The JSON object of that event will then be appended to a list
167 stored in Redis, using <em>format-name</em> as the default key name. Multiple
168 <code>RedisLogOnEvent</code> directives can be used, for different log formats
169 for different events.
170
171 <p>
172 The optional <em>key</em> parameter, if present, specifies the value to use
173 as the Redis key. This <em>key</em> parameter supports all of the
174 <code>LogFormat</code> variables, thus you can use <i>e.g.</i>:
175 <pre>
176 RedisLogOnEvent READ ftp.download.%u.%m:%f
177 </pre>
178
179 <p>
180 More on the use of Redis logging, including a table showing how
181 <code>LogFormat</code> variables are mapped to JSON object keys can be found
182 <a href="#Logging">here</a>.
183
184 <p>
185 Example:
186 <pre>
187 LogFormat sessions "%{iso8601} %a"
188 RedisLogOnEvent CONNECT,DISCONNECT sessions
189 </pre>
190
191 <p>
192 In addition to specific FTP commands, the <em>events</em> list can specify
193 "ALL", for logging on <b>all</b> commands. Or it can <i>include</i> the
194 "CONNECT" and "DISCONNECT" <i>events</i>, which can be useful for logging the
195 start and end times of a session. <b>Note</b> that
196 <code>RedisLogOnEvent</code> <i>does</i> support the logging <i>classes</i>
197 that the <code>ExtendedLog</code> directive supports.
198
199 <p>
200 <hr>
201 <h3><a name="RedisOptions">RedisOptions</a></h3>
202 <strong>Syntax:</strong> RedisOptions <em>opt1 ...</em><br>
203 <strong>Default:</strong> None<br>
204 <strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code><br>
205 <strong>Module:</strong> mod_redis<br>
206 <strong>Compatibility:</strong> 1.3.7rc1 and later
207
208 <p>
209 The <code>RedisOptions</code> directive is used to configure various optional
210 behavior of <code>mod_redis</code>.
211
212 <p>
213 Example:
214 <pre>
215 RedisOptions NoReconnect
216 </pre>
217
218 <p>
219 The currently implemented options are:
220 <ul>
221 <li><code>NoReconnect</code><br>
222 <p>
223 If the connection to Redis breaks unexpectedly, <code>mod_redis</code>
224 will attempt to <em>reconnect</em> automatically. Use this option to
225 disable the automatic reconnection.
226 </li>
227 </ul>
228
229 <p>
230 <hr>
231 <h3><a name="RedisSentinel">RedisSentinel</a></h3>
232 <strong>Syntax:</strong> RedisSentinel <em>host1 ... ["master" name] [ssl:true] [ssl-ca:&lt;path&gt;] [ssl-cert:&lt;path&gt;] [ssl-key:&lt;path&gt;]</em><br>
233 <strong>Default:</strong> None<br>
234 <strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code><br>
235 <strong>Module:</strong> mod_redis<br>
236 <strong>Compatibility:</strong> 1.3.7rc1 and later
237
238 <p>
239 The <code>RedisSentinel</code> directive is used to configure a list of IP
240 addresses/ports of Redis Sentinels that the <code>mod_redis</code> module is
241 to use, for discovering the location of named <em>master</em> database. For
242 example:
243 <pre>
244 # Configure two Sentinels; the first master discovered will be used
245 RedisSentinel 1.2.3.4:26379 5.6.7.8:36379
246
247 # Configure two Sentinels on the default Sentinel port, and
248 # look for the location of the master named "proftpd".
249 RedisSentinel 1.2.3.4 5.6.7.8 master proftpd
250
251 # Configure three Sentinels including an IPv6 address, with explicit ports,
252 # and look for the location of the "proftpd" master.
253 RedisSentinel redis1.example.com:26379 1.2.3.4:26379 [::1]:26379 master proftpd
254 </pre>
255
256 <p>
257 The <code>RedisSentinel</code> directive can be used <em>instead of</em> the
258 <code>RedisServer</code> directive, for discovering the Redis server to use.
259 <b>However</b>, if your Redis server requires authentication, <b>or</b>
260 supports multiple databases, then you <b>will</b> need to use
261 <code>RedisServer</code> as well:
262 <pre>
263 # Use this to configure our password and database
264 RedisServer 127.0.0.1:6379 redis redisr0cks 2
265
266 # And use Sentinels to discover the true address/port
267 RedisSentinel 1.2.3.4 5.6.7.8 9.10.11.12
268 </pre>
269
270 <p>
271 In ProFTPD 1.3.8rc1 and later, it is possible to configure SSL/TLS parameters
272 when connecting to Redis Sentinel. Most of the time, all that is needed for
273 the SSL/TLS session is the CA (Certificate Authority) to use, for verifying the
274 certificate presented by the Redis sentine. Thus:
275 <pre>
276 RedisSentinel ... ssl:true ssl-ca:/path/to/cacert.pem
277 </pre>
278 If your Redis sentinel is configured to require SSL/TLS mutual authentication
279 (also called "client auth"), you may need the <code>ssl-cert:</code> and
280 <code>ssl-key:</code> parameters as well:
281 <pre>
282 RedisSentinel ... ssl:true \
283 ssl-ca:/path/to/cacert.pem \
284 ssl-cert:/path/to/client-cert.pem \
285 ssl-key:/path/to/client-key.pem
286 </pre>
287
288 <p>
289 <hr>
290 <h3><a name="RedisServer">RedisServer</a></h3>
291 <strong>Syntax:</strong> RedisServer <em>server [username] [password] [db-index][ssl:true] [ssl-ca:&lt;path&gt;] [ssl-cert:&lt;path&gt;] [ssl-key:&lt;path&gt;]</em><br>
292 <strong>Default:</strong> None<br>
293 <strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code><br>
294 <strong>Module:</strong> mod_redis<br>
295 <strong>Compatibility:</strong> 1.3.6rc5 and later
296
297 <p>
298 The <code>RedisServer</code> directive is used to configure the IP address/port
299 of the Redis server that the <code>mod_redis</code> module is to use. For
300 example:
301 <pre>
302 RedisServer 1.2.3.4:6379
303 </pre>
304 or, for an IPv6 address, make sure the IPv6 address is enclosed in square
305 brackets:
306 <pre>
307 RedisServer [::ffff:1.2.3.4]:6379
308 </pre>
309
310 <p>
311 Alternatively, you can configure a Unix domain socket path using <i>e.g.</i>:
312 <pre>
313 RedisServer /var/run/redis.sock
314 </pre>
315
316 <p>
317 Optional <em>username</em> and <em>password</em> parameters can be provided,
318 for Redis servers which are password protected.
319
320 <p>
321 As of ProFTPD 1.3.7rc1, the optional <em>db-index</em> parameter can be
322 provided, for <i>selecting</i> the server-side Redis database by index:
323 <pre>
324 RedisServer 1.2.3.4:6379 user passwd 2
325 </pre>
326 Connecting to a Redis server without password authentication <i>but</i> still
327 selecting the database would be done using the empty string for the username
328 and password:
329 <pre>
330 RedisServer 1.2.3.4:6379 "" "" 2
331 </pre>
332
333 <p>
334 In ProFTPD 1.3.8rc1 and later, it is possible to configure SSL/TLS parameters
335 when connecting to Redis. Most of the time, all that is needed for the SSL/TLS
336 session is the CA (Certificate Authority) to use, for verifying the certificate
337 presented by the Redis server. Thus:
338 <pre>
339 RedisServer ... ssl:true ssl-ca:/path/to/cacert.pem
340 </pre>
341 If your Redis server is configured to require SSL/TLS mutual authentication
342 (also called "client auth"), you may need the <code>ssl-cert:</code> and
343 <code>ssl-key:</code> parameters as well:
344 <pre>
345 RedisServer ... ssl:true \
346 ssl-ca:/path/to/cacert.pem \
347 ssl-cert:/path/to/client-cert.pem \
348 ssl-key:/path/to/client-key.pem
349 </pre>
350
351 <p>
352 <hr>
353 <h3><a name="RedisTimeouts">RedisTimeouts</a></h3>
354 <strong>Syntax:</strong> RedisTimeouts <em>connect-millis io-millis</em><br>
355 <strong>Default:</strong> RedisTimeouts 500 500<br>
356 <strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code><br>
357 <strong>Module:</strong> mod_redis<br>
358 <strong>Compatibility:</strong> 1.3.6rc5 and later
359
360 <p>
361 The <code>RedisTimeouts</code> directive configures timeouts to be used
362 when communicating with the Redis server. The <em>connect-millis</em>
363 parameter specifies a timeout, in milliseconds, to use when first
364 connecting to the Redis server. The <em>io-millis</em> parameter specifies
365 a timeout, in milliseconds, to use both when sending commands to Redis, and
366 when reading responses.
367
368 <p>
369 The default is 500 milliseconds for both timeouts:
370 <pre>
371 RedisTimeouts 500 500
372 </pre>
373
374 <p>
375 <hr>
376 <h2><a name="Installation">Installation</a></h2>
377 The <code>mod_redis</code> module is distributed with ProFTPD. To enable
378 support and use of the Redis protocol in your <code>proftpd</code> daemon,
379 use the <code>--enable-redis</code> configure option:
380 <pre>
381 $ ./configure --enable-redis ...
382 $ make
383 $ make install
384 </pre>
385 This option causes the <code>mod_redis</code> module to be compiled into
386 <code>proftpd</code>.
387
388 <p>
389 You may also need to tell <code>configure</code> how to find the
390 <code>hiredis</code> header and library files:
391 <pre>
392 $ ./configure --enable-redis \
393 --with-includes=<i>/path/to/hiredis/include</i> \
394 --with-libraries=<i>/path/to/hiredis/lib</i>
395 </pre>
396
397 <p>
398 <hr>
399 <h2><a name="Usage">Usage</a></h2>
400
401 <p>
402 Configuring Redis for use by other modules, <i>e.g.</i> <code>mod_ban</code>
403 or <code>mod_tls_redis</code>:
404 <pre>
405 &lt;IfModule mod_redis.c&gt;
406 RedisEngine on
407 RedisLog /var/log/ftpd/redis.log
408 RedisServer 127.0.0.1:6379
409 &lt;/IfModule&gt;
410 </pre>
411
412 <p>
413 This example shows the use of Redis logging for <em>all</em> commands:
414 <pre>
415 &lt;IfModule mod_redis.c&gt;
416 RedisEngine on
417 RedisLog /var/log/ftpd/redis.log
418 RedisServer 127.0.0.1:6379
419
420 LogFormat redis "%h %l %u %t \"%r\" %s %b"
421 RedisLogOnCommand ALL redis
422 &lt;/IfModule&gt;
423 </pre>
424
425 <p><a name="Logging"></a>
426 <b>Redis Logging</b><br>
427 When using Redis logging, the following table shows how <code>mod_redis</code>
428 converts a <code>LogFormat</code> variable into the key names in the JSON
429 logging objects:
430 <table border=1 summary="Redis LogFormat Variables">
431 <tr>
432 <td><b><code>LogFormat</code> Variable</b></td>
433 <td><b>Key</b></td>
434 </tr>
435
436 <tr>
437 <td>&nbsp;<code>%A</code>&nbsp;</td>
438 <td>anon_password</td>
439 </tr>
440
441 <tr>
442 <td>&nbsp;<code>%a</code>&nbsp;</td>
443 <td>remote_ip</td>
444 </tr>
445
446 <tr>
447 <td>&nbsp;<code>%b</code>&nbsp;</td>
448 <td>bytes_sent</td>
449 </tr>
450
451 <tr>
452 <td>&nbsp;<code>%c</code>&nbsp;</td>
453 <td>connection_class</td>
454 </tr>
455
456 <tr>
457 <td>&nbsp;<code>%D</code>&nbsp;</td>
458 <td>dir_path</td>
459 </tr>
460
461 <tr>
462 <td>&nbsp;<code>%d</code>&nbsp;</td>
463 <td>dir_name</td>
464 </tr>
465
466 <tr>
467 <td>&nbsp;<code>%E</code>&nbsp;</td>
468 <td>session_end_reason</td>
469 </tr>
470
471 <tr>
472 <td>&nbsp;<code>%{epoch}</code>&nbsp;</td>
473 <td>Unix timestamp, in seconds since Jan 1 1970.</td>
474 </tr>
475
476 <tr>
477 <td>&nbsp;<code>%{<em>name</em>}e</code>&nbsp;</td>
478 <td>ENV:<em>name</em></td>
479 </tr>
480
481 <tr>
482 <td>&nbsp;<code>%F</code>&nbsp;</td>
483 <td>transfer_path</td>
484 </tr>
485
486 <tr>
487 <td>&nbsp;<code>%f</code>&nbsp;</td>
488 <td>file</td>
489 </tr>
490
491 <tr>
492 <td>&nbsp;<code>%{file-modified}</code>&nbsp;</td>
493 <td>file_modified</td>
494 </tr>
495
496 <tr>
497 <td>&nbsp;<code>%g</code>&nbsp;</td>
498 <td>group</td>
499 </tr>
500
501 <tr>
502 <td>&nbsp;<code>%{gid}</code>&nbsp;</td>
503 <td>gid</td>
504 </tr>
505
506 <tr>
507 <td>&nbsp;<code>%H</code>&nbsp;</td>
508 <td>server_ip</td>
509 </tr>
510
511 <tr>
512 <td>&nbsp;<code>%h</code>&nbsp;</td>
513 <td>remote_dns</td>
514 </tr>
515
516 <tr>
517 <td>&nbsp;<code>%I</code>&nbsp;</td>
518 <td>session_bytes_rcvd</td>
519 </tr>
520
521 <tr>
522 <td>&nbsp;<code>%{iso8601}</code>&nbsp;</td>
523 <td>timestamp</td>
524 </tr>
525
526 <tr>
527 <td>&nbsp;<code>%J</code>&nbsp;</td>
528 <td>command_params</td>
529 </tr>
530
531 <tr>
532 <td>&nbsp;<code>%L</code>&nbsp;</td>
533 <td>local_ip</td>
534 </tr>
535
536 <tr>
537 <td>&nbsp;<code>%l</code>&nbsp;</td>
538 <td>identd_user</td>
539 </tr>
540
541 <tr>
542 <td>&nbsp;<code>%m</code>&nbsp;</td>
543 <td>command</td>
544 </tr>
545
546 <tr>
547 <td>&nbsp;<code>%{microsecs}</code>&nbsp;</td>
548 <td>microsecs</td>
549 </tr>
550
551 <tr>
552 <td>&nbsp;<code>%{millisecs}</code>&nbsp;</td>
553 <td>millisecs</td>
554 </tr>
555
556 <tr>
557 <td>&nbsp;<code>%{note:<em>name</em>}</code>&nbsp;</td>
558 <td>NOTE:<em>name</em></td>
559 </tr>
560
561 <tr>
562 <td>&nbsp;<code>%O</code>&nbsp;</td>
563 <td>session_bytes_sent</td>
564 </tr>
565
566 <tr>
567 <td>&nbsp;<code>%P</code>&nbsp;</td>
568 <td>pid</td>
569 </tr>
570
571 <tr>
572 <td>&nbsp;<code>%p</code>&nbsp;</td>
573 <td>local_port</td>
574 </tr>
575
576 <tr>
577 <td>&nbsp;<code>%{protocol}</code>&nbsp;</td>
578 <td>protocol</td>
579 </tr>
580
581 <tr>
582 <td>&nbsp;<code>%r</code>&nbsp;</td>
583 <td>raw_command</td>
584 </tr>
585
586 <tr>
587 <td>&nbsp;<code>%S</code>&nbsp;</td>
588 <td>response_msg</td>
589 </tr>
590
591 <tr>
592 <td>&nbsp;<code>%s</code>&nbsp;</td>
593 <td>response_code</td>
594 </tr>
595
596 <tr>
597 <td>&nbsp;<code>%T</code>&nbsp;</td>
598 <td>transfer_secs</td>
599 </tr>
600
601 <tr>
602 <td>&nbsp;<code>%t</code>&nbsp;</td>
603 <td>local_time</td>
604 </tr>
605
606 <tr>
607 <td>&nbsp;<code>%{transfer-failure}</code>&nbsp;</td>
608 <td>transfer_failure</td>
609 </tr>
610
611 <tr>
612 <td>&nbsp;<code>%{transfer-status}</code>&nbsp;</td>
613 <td>transfer_status</td>
614 </tr>
615
616 <tr>
617 <td>&nbsp;<code>%U</code>&nbsp;</td>
618 <td>original_user</td>
619 </tr>
620
621 <tr>
622 <td>&nbsp;<code>%u</code>&nbsp;</td>
623 <td>user</td>
624 </tr>
625
626 <tr>
627 <td>&nbsp;<code>%{uid}</code>&nbsp;</td>
628 <td>uid</td>
629 </tr>
630
631 <tr>
632 <td>&nbsp;<code>%V</code>&nbsp;</td>
633 <td>server_dns</td>
634 </tr>
635
636 <tr>
637 <td>&nbsp;<code>%v</code>&nbsp;</td>
638 <td>server_name</td>
639 </tr>
640
641 <tr>
642 <td>&nbsp;<code>%{version}</code>&nbsp;</td>
643 <td>server_version</td>
644 </tr>
645
646 <tr>
647 <td>&nbsp;<code>%w</code>&nbsp;</td>
648 <td>rename_from</td>
649 </tr>
650 </table>
651
652 <p>
653 In addition to the standard <code>LogFormat</code> variables, the
654 <code>mod_redis</code> module also adds a "connecting" key for events
655 generated when a client first connects, and a "disconnecting" key for events
656 generated when a client disconnects. These keys can be used for determining
657 the start/finish events for a given session.
658
659 <p>
660 Here is an example of the JSON-formatted records generated, using the above
661 example configuration:
662 <pre>
663 {"connecting":true,"timestamp":"2013-08-21 23:08:22,171"}
664 {"command":"USER","timestamp":"2013-08-21 23:08:22,278"}
665 {"user":"proftpd","command":"PASS","timestamp":"2013-08-21 23:08:22,305"}
666 {"user":"proftpd","command":"PASV","timestamp":"2013-08-21 23:08:22,317"}
667 {"user":"proftpd","command":"LIST","bytes_sent":432,"transfer_secs":4.211,"timestamp":"2013-08-21 23:08:22,329"}
668 {"user":"proftpd","command":"QUIT","timestamp":"2013-08-21 23:08:22,336"}
669 {"disconnecting":true,"user":"proftpd","timestamp":"2013-08-21 23:08:22,348"}
670 </pre>
671 Notice that for a given event, not <i>all</i> of the <code>LogFormat</code>
672 variables are filled in. If <code>mod_redis</code> determines that a given
673 <code>LogFormat</code> variable has no value for the logged event, it will
674 simply omit that variable from the JSON object.
675
676 <p>
677 Another thing to notice is that the generated JSON object ignores the textual
678 delimiters configured by the <code>LogFormat</code> directive; all that
679 matters are the <code>LogFormat</code> variables which appear in the directive.
680
681 <p><a name="FAQ"></a>
682 <b>Frequently Asked Questions</b><br>
683
684 <p><a name="SQLLog"></a>
685 <font color=red>Question</font>: How can I convert this SQL logging into the
686 equivalent Redis logging?
687 <pre>
688 SQLNamedQuery upload FREEFORM "INSERT INTO ftplogs ('userid', 'server_ip', 'transfer_date', 'operation', 'protocol', 'client_ip', 'transfer_time', 'bytes_transfer', 'file_hash_type', 'file_hash', 'file_path', 'transfer_status') VALUES ('%u', '%H', NOW(), '%r', '%{protocol}', '%a', '%T', '%b', '%{note:mod_digest.algo}', '%{note:mod_digest.digest}', '%f', '%{transfer-status}')"
689 SQLLog STOR upload
690 </pre>
691 <font color=blue>Answer</font>: Since the JSON object key names are hardcoded
692 in <code>mod_redis</code>, converting the above <code>SQLNamedQuery</code>
693 into a suitable/matching <code>LogFormat</code> is the necessary step. Thus
694 for example it might become:
695 <pre>
696 LogFormat upload "%u %H %{YYYY-MM-DD HH:MM:SS}t %r %{protocol} %a %T %b %{note:mod_digest.algo} %{note:mod_digest.digest} %f %{transfer-status}"
697 RedisLogOnCommand STOR upload
698 </pre>
699 <b>Note</b> that <code>LogFormat</code> does not provide a <code>NOW()</code>
700 function, unlike many SQL databases, thus the <code>%t</code> variable is
701 needed to provide/fill in that timestamp.
702
703 <p>
704 <hr>
705 <font size=2><b><i>
706 &copy; Copyright 2017-2021 The ProFTPD Project<br>
707 All Rights Reserved<br>
708 </i></b></font>
709 <hr>
710
711 </body>
712 </html>