-
Notifications
You must be signed in to change notification settings - Fork 18
/
mod_proxy.html
2570 lines (2267 loc) · 96.6 KB
/
mod_proxy.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<title>ProFTPD module mod_proxy</title>
</head>
<body bgcolor=white>
<hr>
<center>
<h2><b>ProFTPD module <code>mod_proxy</code></b></h2>
</center>
<hr><br>
<p>
The purpose of the <code>mod_proxy</code> module is to provide FTP proxying
capabilities in <code>proftpd</code>, both <em>reverse</em> (or "gateway")
proxying and <em>forward</em> proxying.
<p>
Installation instructions are discussed <a href="#Installation">here</a>.
<b>Note</b> that <code>mod_proxy</code> requires ProFTPD 1.3.6rc2 or later.
Detailed notes on best practices for using this module are
<a href="#Usage">here</a>.
<p>
This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/).
<p>
This product includes cryptographic software written by Eric Young ([email protected]).
<p>
The most current version of <code>mod_proxy</code> can be found at:
<pre>
<a href="https://github.com/Castaglia/proftpd-mod_proxy.git">https://github.com/Castaglia/proftpd-mod_proxy.git</a>
</pre>
<h2>Author</h2>
<p>
Please contact TJ Saunders <tj <i>at</i> castaglia.org> with any
questions, concerns, or suggestions regarding this module.
<h2>Thanks</h2>
<p>
<i>2015-08-24</i>: Thanks to Michael Toth <mtoth <i>at</i> queldor.net>
for helping test multiple iterations of <code>mod_proxy</code> with IIS
servers.
<h2>Directives</h2>
<ul>
<li><a href="#ProxyDataTransferPolicy">ProxyDataTransferPolicy</a>
<li><a href="#ProxyDatastore">ProxyDatastore</a>
<li><a href="#ProxyDirectoryListPolicy">ProxyDirectoryListPolicy</a>
<li><a href="#ProxyEngine">ProxyEngine</a>
<li><a href="#ProxyForwardEnabled">ProxyForwardEnabled</a>
<li><a href="#ProxyForwardMethod">ProxyForwardMethod</a>
<li><a href="#ProxyForwardTo">ProxyForwardTo</a>
<li><a href="#ProxyLog">ProxyLog</a>
<li><a href="#ProxyOptions">ProxyOptions</a>
<li><a href="#ProxyReverseConnectPolicy">ProxyReverseConnectPolicy</a>
<li><a href="#ProxyReverseServers">ProxyReverseServers</a>
<li><a href="#ProxyRetryCount">ProxyRetryCount</a>
<li><a href="#ProxyRole">ProxyRole</a>
<li><a href="#ProxySFTPCiphers">ProxySFTPCiphers</a>
<li><a href="#ProxySFTPCompression">ProxySFTPCompression</a>
<li><a href="#ProxySFTPDigests">ProxySFTPDigests</a>
<li><a href="#ProxySFTPHostKey">ProxySFTPHostKey</a>
<li><a href="#ProxySFTPKeyExchanges">ProxySFTPKeyExchanges</a>
<li><a href="#ProxySFTPOptions">ProxySFTPOptions</a>
<li><a href="#ProxySFTPPassPhraseProvider">ProxySFTPPassPhraseProvider</a>
<li><a href="#ProxySFTPServerAlive">ProxySFTPServerAlive</a>
<li><a href="#ProxySFTPServerMatch">ProxySFTPServerMatch</a>
<li><a href="#ProxySFTPVerifyServer">ProxySFTPVerifyServer</a>
<li><a href="#ProxySourceAddress">ProxySourceAddress</a>
<li><a href="#ProxyTables">ProxyTables</a>
<li><a href="#ProxyTimeoutConnect">ProxyTimeoutConnect</a>
<li><a href="#ProxyTimeoutLinger">ProxyTimeoutLinger</a>
<li><a href="#ProxyTLSCACertificateFile">ProxyTLSCACertificateFile</a>
<li><a href="#ProxyTLSCACertificatePath">ProxyTLSCACertificatePath</a>
<li><a href="#ProxyTLSCARevocationFile">ProxyTLSCARevocationFile</a>
<li><a href="#ProxyTLSCARevocationPath">ProxyTLSCARevocationPath</a>
<li><a href="#ProxyTLSCertificateFile">ProxyTLSCertificateFile</a>
<li><a href="#ProxyTLSCertificateKeyFile">ProxyTLSCertificateKeyFile</a>
<li><a href="#ProxyTLSCipherSuite">ProxyTLSCipherSuite</a>
<li><a href="#ProxyTLSEngine">ProxyTLSEngine</a>
<li><a href="#ProxyTLSOptions">ProxyTLSOptions</a>
<li><a href="#ProxyTLSPreSharedKey">ProxyTLSPreSharedKey</a>
<li><a href="#ProxyTLSProtocol">ProxyTLSProtocol</a>
<li><a href="#ProxyTLSTimeoutHandshake">ProxyTLSTimeoutHandshake</a>
<li><a href="#ProxyTLSTransferProtectionPolicy">ProxyTLSTransferProtectionPolicy</a>
<li><a href="#ProxyTLSVerifyServer">ProxyTLSVerifyServer</a>
</ul>
<p>
<hr>
<h3><a name="ProxyDataTransferPolicy">ProxyDataTransferPolicy</a></h3>
<strong>Syntax:</strong> ProxyDataTransferPolicy <em>client|active|passive|pasv|epsv|port|eprt</em><br>
<strong>Default:</strong> ProxyDataTransferPolicy client<br>
<strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br>
<strong>Module:</strong> mod_proxy<br>
<strong>Compatibility:</strong> 1.3.6rc1 and later
<p>
The <code>ProxyDataTransferPolicy</code> directive configures the data
transfer <em>policy</em> that <code>mod_proxy</code> uses when performing
data transfers (<i>e.g.</i> file uploads/downloads, directory listings) with
the backend/destination server.
<p>
The currently supported policies are:
<ul>
<li><code>client</code>
<p>
This policy indicates that <code>mod_proxy</code> will use whatever
the connected client uses. Thus if the client sends <code>PORT</code>,
<code>mod_proxy</code> will send <code>PORT</code> to the
backend/destination server.
<p>
This is the <em>recommended policy</em> in most cases.
</li>
<p>
<li><code>active</code>
<p>
Regardless of the commands sent by the client, <code>mod_proxy</code>
will use only <em>active</em> data transfers (<i>i.e.</i> using
<code>PORT</code> commands) with the backend/destination server.
</li>
<p>
<li><code>passive</code>
<p>
Regardless of the commands sent by the client, <code>mod_proxy</code>
will use only <em>passive</em> data transfers (<i>i.e.</i> using
<code>PASV</code> commands) with the backend/destination server.
</li>
<p>
<li><code>PASV</code>
<p>
Regardless of the commands sent by the client, <code>mod_proxy</code>
will use only <code>PASV</code> commands with the backend/destination
server.
</li>
<p>
<li><code>PORT</code>
<p>
Regardless of the commands sent by the client, <code>mod_proxy</code>
will use only <code>PORT</code> commands with the backend/destination
server.
</li>
<p>
<li><code>EPSV</code>
<p>
Regardless of the commands sent by the client, <code>mod_proxy</code>
will use only <code>EPSV</code> commands with the backend/destination
server.
</li>
<p>
<li><code>EPRT</code>
<p>
Regardless of the commands sent by the client, <code>mod_proxy</code>
will use only <code>EPRT</code> commands with the backend/destination
server.
</li>
</ul>
<p>
<hr>
<h3><a name="ProxyDatastore">ProxyDatastore</a></h3>
<strong>Syntax:</strong> ProxyDatastore <em>type [info]</em><br>
<strong>Default:</strong> ProxyDatastore SQLite<br>
<strong>Context:</strong> server config<br>
<strong>Module:</strong> mod_proxy<br>
<strong>Compatibility:</strong> 1.3.6rc1 and later
<p>
The <code>ProxyDatastore</code> directive configures the <em>type</em> of
datastore that <code>mod_proxy</code> uses for persistence. The currently
supported datastore <em>types</em> are:
<ul>
<li>Redis
<li>SQLite
</ul>
<p>
<b>Note</b> that the Redis <em>type</em> also requires the <em>info</em>
parameter, namely a prefix for all of the Redis keys. This prefix <b>must</b>
be different/unique among all of your <code>mod_proxy</code> servers using
that Redis server/cluster; the prefix is used to keep all of the data
<i>for this server</i> separate from all other servers. For example:
<pre>
<IfModule mod_proxy.c>
...
<IfModule mod_redis.c>
# Use our IP address as our prefix
ProxyDatastore Redis 1.2.3.4.
</IfModule>
</IfModule>
</pre>
<p>
<hr>
<h3><a name="ProxyDirectoryListPolicy">ProxyDirectoryListPolicy</a></h3>
<strong>Syntax:</strong> ProxyDirectoryListPolicy <em>client|"LIST" [opt1 ...]</em><br>
<strong>Default:</strong> ProxyDirectoryListPolicy client<br>
<strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br>
<strong>Module:</strong> mod_proxy<br>
<strong>Compatibility:</strong> 1.3.6rc1 and later
<p>
The <code>ProxyDirectoryListPolicy</code> directive configures the directory
list <em>policy</em> that <code>mod_proxy</code> uses when performing
directory lists with the backend/destination server.
<p>
The currently supported policies are:
<ul>
<li><code>client</code>
<p>
This policy indicates that <code>mod_proxy</code> will use whatever
the connected client uses. Thus if the client sends <code>MLSD</code>,
<code>mod_proxy</code> will send <code>MLSD</code> to the
backend/destination server.
<p>
This is the <em>recommended policy</em> in most cases.
</li>
<p>
<li><code>LIST</code>
<p>
This policy instructs <code>mod_proxy</code> to use the <code>LIST</code>
command with the backend/destination server, regardless of the command
used by the client. The <code>mod_proxy</code> module then handles any
reformatting of the <code>LIST</code> response into the response needed
by the client. For example, if the client sends <code>MLSD</code> but the
backend/destination server does not support this command,
<code>mod_proxy</code> will send <code>LIST</code> instead, and translate
the backend format into the client-requested format.
<p>
The current implementation of this policy handles <code>LIST-<MLSD</code>
translations only.
</li>
</ul>
You may also provide <em>options</em>; the currently implemented
<em>options</em> are:
<ul>
<li><code>UseSlink</code><br>
<p>
Use this option to have <code>mod_proxy</code> use the <i>broken</i>
"OS.unix=slink" syntax, preferred by FTP clients such as FileZilla, for
indicating symlinks, rather than the more correct "OS.unix=symlink"
syntax. See
<a href="http://bugs.proftpd.org/show_bug.cgi?id=3318">Bug#3318</a> for
a more detailed discussion.
</li>
</ul>
<p>
<hr>
<h3><a name="ProxyEngine">ProxyEngine</a></h3>
<strong>Syntax:</strong> ProxyEngine <em>on|off</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br>
<strong>Module:</strong> mod_proxy<br>
<strong>Compatibility:</strong> 1.3.6rc1 and later
<p>
The <code>ProxyEngine</code> directive toggles the support for proxying by
<code>mod_proxy</code>. This is usually used inside a
<code><VirtualHost></code> section to enable proxying of FTP sessions for
a particular virtual host. By default <code>mod_proxy</code> is disabled for
both the main server and all configured virtual hosts.
<p>
<hr>
<h3><a name="ProxyForwardEnabled">ProxyForwardEnabled</a></h3>
<strong>Syntax:</strong> ProxyForwardEnabled <em>on|off</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> <code><Class></code><br>
<strong>Module:</strong> mod_proxy<br>
<strong>Compatibility:</strong> 1.3.6rc2 and later
<p>
The <code>ProxyForwardEnabled</code> directive determines whether a client
can use <code>mod_proxy</code> for forward proxying, based on that client's
<a href="http://www.proftpd.org/docs/howto/Classes.html">class</a>.
<p>
By default, <code>mod_proxy</code> rejects any forward proxy request from
<b>any</b> client, with the exception of clients connecting from
<a href="http://www.faqs.org/rfcs/rfc1918.html">RFC 1918</a> addresses:
<pre>
192.168.0.0/16
172.16.0.0/12
10.0.0.0/8
</pre>
This is done as a security measure: <b>open/unrestricted proxy servers are
dangerous both to your network and to the Internet at large</b>. Thus to make
it possible for clients to use your server for forward proxying, they <b>must
be explicitly</b> enabled to do so.
<p>
Example:
<pre>
<Class forward-proxy>
From 1.2.3.4/12
# Allow clients from this class to use FTP forward proxying
ProxyForwardEnabled on
</Class>
</pre>
<p>
See also: <a href="#ProxyForwardTo"><code>ProxyForwardTo</code></a>
<p>
<hr>
<h3><a name="ProxyForwardMethod">ProxyForwardMethod</a></h3>
<strong>Syntax:</strong> ProxyForwardMethod <em>method</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br>
<strong>Module:</strong> mod_proxy<br>
<strong>Compatibility:</strong> 1.3.6rc1 and later
<p>
The <code>ProxyForwardMethod</code> directive configures the <em>method</em>
that clients can use for requesting forward proxying. Some methods require
that the client authenticate <em>to the proxy first</em>, and then separately
authenticate to the destination server; these methods differ on just when
the client specifies the destination server. Other methods do not require
proxy authentication. There are many variations on a theme with these methods.
<p>
The currently supported methods are:
<ul>
<li><code>proxyuser,user@host</code>
<p>
This method indicates that proxy authentication is <b>required</b>. The
client first authenticates to the proxy via <code>USER/PASS</code> commands:
<pre>
USER <em>proxy-user</em>
PASS <em>proxy-passwd</em>
</pre>
Then the client authenticates <i>again</i>, this time including the
address (and optionally port) of the destination server as part of the
second <code>USER</code> command:
<pre>
USER <em>real-user</em>@ftp.example.com
PASS <em>real-passwd</em>
</pre>
The <code>mod_proxy</code> module will remove the destination address
portion of the second <code>USER</code> command before proxying it to
the destination server.
</li>
<p>
<li><code>proxyuser@host,user</code>
<p>
This method indicates that proxy authentication is <b>required</b>. The
client first authenticates to the proxy via <code>USER/PASS</code> commands;
note that the destination address (and optionally port) is included as part
of the first <code>USER</code> command:
<pre>
USER <em>proxy-user</em>@ftp.example.com
PASS <em>proxy-passwd</em>
</pre>
Then the client authenticates <i>again</i>, this time sending the
<code>USER/PASS</code> commands to authenticate to the destination server:
<pre>
USER <em>real-user</em>
PASS <em>real-passwd</em>
</pre>
</li>
<p>
<li><code>user@host</code>
<p>
This methods indicates that <i>no proxy authentication</i> is used. The
client indicates the destination address (and optionally port) of the
server as part of the <code>USER</code> command:
<pre>
USER <em>real-user</em>@ftp.example.com
PASS <em>real-passwd</em>
</pre>
The <code>mod_proxy</code> module will remove the destination address
portion of the <code>USER</code> command before proxying it to the
destination server.
</li>
<p>
<li><code>user@sni</code>
<p>
This methods indicates that <i>no proxy authentication</i> is used. The
client indicates the destination address (and optionally port) of the
server as part of a TLS SNI (Server Name Indication) portion of a TLS
session:
<pre>
AUTH TLS <em>handshake with SNI</em>
USER <em>real-user</em>
PASS <em>real-passwd</em>
</pre>
</li>
</ul>
<p>
Configuring the FTP client's proxy settings to match the above methods varies
greatly, depending on the FTP client.
<p>
<hr>
<h3><a name="ProxyForwardTo">ProxyForwardTo</a></h3>
<strong>Syntax:</strong> ProxyForwardTo <em>[!]pattern [flags]</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br>
<strong>Module:</strong> mod_proxy<br>
<strong>Compatibility:</strong> 1.3.6rc1 and later
<p>
The <code>ProxyForwardTo</code> directive is used to restrict which
hosts/domains can be requested for forward proxying. The destination host/port
for forward proxying <b>must</b> match the configured <em>pattern</em>
regular expression, or the forward proxying request will fail.
<p>
The optional <em>flags</em> parameter, if present, modifies how the given
<em>pattern</em> will be evaludated. The supported flags are:
<ul>
<li><b>nocase|NC</b> (<b>n</b>o <b>c</b>ase)<br>
This makes the <em>pattern</em> case-insensitive, <i>i.e.</i> there is
no difference between 'A-Z' and 'a-z' when <em>pattern</em> is matched
against the path
</li>
</ul>
<p>
<code>ProxyForwardTo</code> limits the destination hosts <b>to</b> which
clients can request forward proxying; by contrast,
<a href="#ProxyForwardEnabled"><code>ProxyForwardEnabled</code></a> controls
forward proxying based on where clients connect <b>from</b>.
<p>
Example:
<pre>
# Limit forward proxying to specific host and port
ProxyForwardTo ^ftp.example.com:21$
</pre>
<p>
<hr>
<h3><a name="ProxyLog">ProxyLog</a></h3>
<strong>Syntax:</strong> ProxyLog <em>path|"none"</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br>
<strong>Module:</strong> mod_proxy<br>
<strong>Compatibility:</strong> 1.3.6rc1 and later
<p>
The <code>ProxyLog</code> directive is used to specify a log file for
<code>mod_proxy</code>'s reporting on a per-server basis. The <em>path</em>
parameter given must be the full path to the file to use for logging.
<p>
Note that this path must <b>not</b> be to a world-writable directory and,
unless <code>AllowLogSymlinks</code> is explicitly set to <em>on</em>
(generally a bad idea), the path must <b>not</b> be a symbolic link.
<p>
<hr>
<h3><a name="ProxyOptions">ProxyOptions</a></h3>
<strong>Syntax:</strong> ProxyOptions <em>opt1 ...</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br>
<strong>Module:</strong> mod_proxy<br>
<strong>Compatibility:</strong> 1.3.6rc1 and later
<p>
The <code>ProxyOptions</code> directive is used to configure various optional
behavior of <code>mod_proxy</code>. For example:
<pre>
ProxyOptions UseProxyProtocolV1
</pre>
<p>
The currently implemented options are:
<ul>
<li><code>AllowForeignAddress</code><br>
<p>
The <a href="http://www.proftpd.org/docs/modules/mod_core.html#AllowForeignAddress"><code>AllowForeignAddress</code></a> directive controls the policy for
<i>frontend</i> data transfer requests from clients connecting to the proxy
server; it does <b>not</b> apply to <i>backend</i> data transfer requests.
For those, you will want to use this <code>AllowForeignAddress</code>
option:
<pre>
# Allow for cases where the backend server tells us to use a different IP
# address for data transfers than the IP address to which mod_proxy connected.
ProxyOptions AllowForeignAddress
</pre>
</li>
<p>
<li><code>ShowFeatures</code><br>
<p>
When reverse proxying, <code>mod_proxy</code> defaults to not responding to
the FTP <code>FEAT</code> command, which is used to determine the supported
features/capabilities of the FTP server; this is done to prevent leaking
of information about internal FTP servers to the outside world. However,
some clients rely on the <code>FEAT</code> data. For such clients/use
cases, use this option to tell <code>mod_proxy</code> to proxy the
<code>FEAT</code> command/response to the backend server.
</li>
<p>
<li><code>UseDirectDataTransfers</code><br>
<p>
The <code>mod_proxy</code> module will, by default, proxy all data transfers
through the proxy server. Some sites may wish to have the FTP data
transfers occur directly between the frontend client and the backend server,
to avoid the latency/overhead of the proxying. Use this option to
enable these direct data transfers (akin to <b>D</b>irect <b>S</b>erver
<b>R</b>eturn, or DSR), for both forward and reverse proxy roles:
<pre>
# Enable data transfers directly from frontend client to/from backend server
ProxyOptions UseDirectDataTransfers
</pre>
</li>
<p>
<li><code>UseProxyProtocolV1</code><br>
<p>
When <code>mod_proxy</code> connects to the backend/destination server,
use the <a href="http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt"><code>PROXY</code></a> V1 protocol, sending the human-readable <code>PROXY</code>
command to the destination server. This allows backend servers to implement
access controls/logging, based on the IP address of the connecting client.
The <a href="https://github.com/Castaglia/proftpd-mod_proxy_protocol"><code>mod_proxy_protocol</code></a>
ProFTPD module can be used to handle the <code>PROXY</code> command on
the receiving side, <i>i.e.</i> when using <code>proftpd</code> as the
backend/destination server.
<p>
<b>Note</b>: do <b>not</b> use this option unless the backend server
<em>does</em> support the <code>PROXY</code> V1 protocol. Otherwise, the
<code>PROXY</code> protocol message will only confuse the backend server,
possibly leading to connection/login failures.
</li>
<p>
<li><code>UseProxyProtocolV2</code><br>
<p>
When <code>mod_proxy</code> connects to the backend/destination server,
use the <a href="http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt"><code>PROXY</code></a> V2 protocol, sending a binary-encoded "PROXY" command
to the destination server. This allows backend servers to implement
access controls/logging, based on the IP address of the connecting client.
The <a href="https://github.com/Castaglia/proftpd-mod_proxy_protocol"><code>mod_proxy_protocol</code></a>
ProFTPD module can be used to handle the "PROXY" command on the receiving
side, <i>i.e.</i> when using <code>proftpd</code> as the
backend/destination server.
<p>
<b>Note</b>: do <b>not</b> use this option unless the backend server
<em>does</em> support the <code>PROXY</code> V2 protocol. Otherwise, the
"PROXY" protocol message will only confuse the backend server, possibly
leading to connection/login failures.
</li>
<p>
<li><code>UseProxyProtocolV2TLVs</code><br>
<p>
When <code>mod_proxy</code> is configured to use the PROXY protocol V2,
via the <code>UseProxyProtocolV2</code> option, this option tells
<code>mod_proxy</code> to send additional data as Type/Length/Value (TLV).
These TLVs include:
<ul>
<li>ALPN (Application Layer Protocol Negotiation)
<li>Authority (Hostname provided by client)
<li>SSL/TLS (whether SSL/TLS is in use at the time of the PROXY protocol)
<li>SSL/TLS protocol version
<li>SSL/TLS cipher
<li>Unique ID (when <a href="http://www.proftpd.org/docs/contrib/mod_unique_id.html"><code>mod_unique_id</code></a> is present/used)
</ul>
<p>
<b>Note</b>: use of the <code>UseProxyProtocolV2</code> option is also
required for the TLVs to be sent.
</li>
<p>
<li><code>UseReverseProxyAuth</code><br>
<p>
When reverse proxying, <code>mod_proxy</code> delegates user authentication
to the selected backend server. However, there are some sites which need
to centralize user authentication in the proxy; use this option to require
proxy authentication for such cases. <b>Note</b> that this option
<b>only</b> pertains to reverse proxy connections; proxy authentication
when forward proxying is determined by the <code>ProxyForwardMethod</code>
directive.
</li>
</ul>
<p>
<hr>
<h3><a name="ProxyRetryCount">ProxyRetryCount</a></h3>
<strong>Syntax:</strong> ProxyRetryCount <em>count</em><br>
<strong>Default:</strong> ProxyRetryCount 5<br>
<strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br>
<strong>Module:</strong> mod_proxy<br>
<strong>Compatibility:</strong> 1.3.6rc1 and later
<p>
The <code>ProxyRetryCount</code> directive configures the number of times
<code>mod_proxy</code> will attempt to connect to the backend/destination
server. The default is <em>5</em> attempts.
<p>
<hr>
<h3><a name="ProxyReverseConnectPolicy">ProxyReverseConnectPolicy</a></h3>
<strong>Syntax:</strong> ProxyReverseConnectPolicy <em>policy</em><br>
<strong>Default:</strong> RoundRobin<br>
<strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br>
<strong>Module:</strong> mod_proxy<br>
<strong>Compatibility:</strong> 1.3.6rc1 and later
<p>
The <code>ProxyReverseConnectPolicy</code> directive configures the
<em>policy</em> that <code>mod_proxy</code> will use for selecting the backend
server when reverse proxying.
<p>
The currently supported policies are:
<ul>
<li><code>LeastConns</code>
<p>
Select the backend server with the lowest number of proxied connections.
</li>
<p>
<li><code>LeastResponseTime</code>
<p>
Select the backend server with the least response time; this is determined
based on the connect time to the backend server, and its number of
current connections.
</li>
<p>
<li><code>PerGroup</code>
<p>
Select a backend server based on the primary group of the authenticated
<code>USER</code> name used by the connecting client; any future
connections using that same <code>USER</code> name will be routed to the
same backend server.
<p>
<b>Note</b>: use of this <code>ProxyReverseConnectPolicy</code> also
<b>requires</b> use of the <code>UseReverseProxyAuth</code>
<code>ProxyOption</code>, as authenticating the given <code>USER</code>
name is required for discovering the primary group of that user.
</li>
<p>
<li><code>PerHost</code>
<p>
Select a backend server based on the IP address of the connecting client;
any future connections from that IP address will be routed to the same
backend server.
</li>
<p>
<li><code>PerUser</code>
<p>
Select a backend server based on the <code>USER</code> name used by the
connecting client; any future connections using that same <code>USER</code>
name will be routed to the same backend server.
</li>
<p>
<li><code>Random</code>
<p>
Randomly select any of the backend servers.
</li>
<p>
<li><code>RoundRobin</code>
<p>
Select the next backend server in the list.
</li>
<p>
<li><code>Shuffle</code>
<p>
Similar to the <code>Random</code> policy, except the selection happens
from the not-yet-chosen backend servers. This means that <b>all</b>
backend servers will eventually be used evenly, just in a random order.
</li>
</ul>
<p>
<hr>
<h3><a name="ProxyReverseServers">ProxyReverseServers</a></h3>
<strong>Syntax:</strong> ProxyReverseServers <em>servers</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br>
<strong>Module:</strong> mod_proxy<br>
<strong>Compatibility:</strong> 1.3.6rc1 and later
<p>
The <code>ProxyReverseServers</code> directive configures the list of servers
to be used as the backend servers for reverse proxying.
<p>
Each server <b>must</b> be configured as a <i>URL</i>. Only the "ftp" and
"ftps" schemes are currently supported. If not specified, the port will be
21. IPv6 addresses <b>must</b> be enclosed within square brackets. Thus, for
example, the following are all valid URLs:
<pre>
ftp://<em>ftp1.example.com:2121</em>
ftp://<em>1.2.3.4</em>
ftp://<em>[::ffff:6.7.8.9]:2121</em>
ftps://<em>ftp2.example.com</em>
ftps://<em>ftp3.example.com:990</em>
</pre>
And using them all in the configuration would look like:
<pre>
ProxyReverseServers ftp://ftp1.example.com:2121 ftps://1.2.3.4 ftp://[::ffff:6.7.8.9]:2121
</pre>
<p>
The backend servers can also be discovered via DNS <code>SRV</code> or <code>TXT</code> records, using <code>SRV/TXT</code> URL scheme variants, <i>e.g.</i>:
<pre>
# Discover backend addresses via DNS SRV records
ftp+srv://_ftp._tcp.castaglia.org
# Discover backend addresses via DNS TXT records (which must be an FTP URL)
ftp+txt://castaglia.org
</pre>
These <code>SRV/TXT</code> URL scheme variations also apply to FTPS URLs.
<b>Note</b> that any explicit port numbers provided in URLs using these
<code>SRV/TXT</code> scheme variants <i>will be ignored</i>; the actual port
numbers to use will be discovered from the <code>SRV</code> and <code>TXT</code>
DNS records.
<p>
The backend servers can <i>also</i> be contained in a list in a JSON file,
<i>e.g.</i>:
<pre>
[
"ftp://ftp1.example.com:2121",
"ftp://[::ffff:6.7.8.9]:2121"
]
</pre>
You then only need to configure the path to that JSON file:
<pre>
ProxyReverseServers file:/path/to/backends.json
</pre>
<p>
<b>Note</b> that <code>mod_proxy</code> has strict requirements for the
permissions on <code>ProxyReverseServers</code> files. The configured file
<em>must not be world-writable</em>, since that would allow <i>any user</i>
on the system to modify the file, directing proxied connections anywhere else.
If a world-writable <code>ProxyReverseServers</code> file is found, you will
see the following error message logged:
<pre>
unable to use world-writable ProxyReverseServers '/opt/proxy/reverse.json' (perms 0666): Operation not permitted
</pre>
In addition, the <i>directory</i> containing the
<code>ProxyReverseServers</code> file cannot be world-writable, either. Even
if the file itself is not world-writable, being in a world-writable directory
means that <i>any user</i> on the system can delete that file, and write a new
file. When a world-writable directory is found, the following error is logged:
<pre>
unable to use ProxyReverseServers '/opt/proxy/reverse.json' from world-writable directory '/opt/proxy' (perms 0777): Operation not permitted
</pre>
<p>
The backend servers can <i>also</i> be provided from an external SQL database,
queried by <code>mod_proxy</code> via <a href="http://www.proftpd.org/docs/contrib/mod_sql.html#SQLNamedQuery"><code>SQLNamedQuery</code></a>. For example,
<i>assuming</i> a schema such as this:
<pre>
CREATE TABLE proxy_user_servers (
user_name TEXT,
url TEXT
);
CREATE INDEX proxy_user_servers_name_idx ON proxy_user_servers (user_name);
</pre>
where <em>url</em> contains URLs, <i>e.g.</i> "ftp://1.2.3.4:21". Then you
would configure <code>mod_proxy</code> to query for those per-user backend URLs
using <code>ProxyReverseServers</code> like this:
<pre>
<IfModule mod_sql.c>
...
SQLNamedQuery get-user-servers SELECT "url FROM proxy_user_servers WHERE user_name = %{0}"
</IfModule>
ProxyRole reverse
ProxyReverseConnectPolicy PerUser
ProxyReverseServers sql:/get-user-servers
</pre>
<p>
Given that <code>mod_proxy</code> uses SQLite, does that mean that the table
used for storing these per-user URLs <b>must</b> be SQLite? <b>No</b>. The
use of <code>SQLNamedQuery</code> means that <b>any database</b>, supported
by <code>mod_sql</code>, can be used.
<p>
<hr>
<h3><a name="ProxyRole">ProxyRole</a></h3>
<strong>Syntax:</strong> ProxyRole <em>role</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br>
<strong>Module:</strong> mod_proxy<br>
<strong>Compatibility:</strong> 1.3.6rc1 and later
<p>
The <code>ProxyRole</code> directive configures whether <code>mod_proxy</code>
will perform forward or reverse proxying. The list of supported <em>roles</em>
are thus:
<ul>
<li><code>forward</code>
<p>
Perform forward proxying.
</li>
<p>
<li><code>reverse</code>
<p>
Perform reverse proxying.
</li>
</ul>
<p>
<b>Note</b> that the <code>ProxyRole</code> directive is <b>required</b>
for <code>mod_proxy</code> to function. If this directive is not configured,
connections to <code>mod_proxy</code> will fail.
<p>
<hr>
<h3><a name="ProxySFTPCiphers">ProxySFTPCiphers</a></h3>
<strong>Syntax:</strong> ProxySFTPCiphers <em>algo1 ...</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br>
<strong>Module:</strong> mod_proxy<br>
<strong>Compatibility:</strong> 1.3.8rc3 and later
<p>
The <code>ProxySFTPCiphers</code> directive is used to specify the list of
cipher algorithms that <code>mod_proxy</code> should use when connecting to
backend SSH servers. The current list of supported cipher algorithms is, in
the default order of preference:
<ul>
<li>aes256-ctr
<li>aes192-ctr
<li>aes128-ctr
<li>aes256-cbc
<li>aes192-cbc
<li>aes128-cbc
<li>cast128-cbc
<li>3des-ctr
<li>3des-cbc
</ul>
By default, all of the above cipher algorithms are presented to the server,
in the above order, during the key exchange.
<p>
The "none" cipher (<i>i.e.</i> no encryption) will <b>not</b> be presented to
the server by default; any sites which wish to use "none" will have to
explicitly configure it via <code>ProxySFTPCiphers</code>.
<p>
Note that CTR mode ciphers (<i>e.g.</i> the <code>aes128-ctr</code>,
<code>aes192-ctr</code>, and <code>aes256-ctr</code> ciphers) are recommended.
Any CBC mode cipher allows for the possibility of an attack which causes
several bits of plaintext to be leaked; the attack is described
<a href="http://www.cpni.gov.uk/Docs/Vulnerability_Advisory_SSH.txt">here</a>.
This attack is on the SSH2 protocol design itself; any SSH2 implementation
which conforms to the RFCs will have this weakness.
<p>
In general, there is no need to use this directive unless only one specific
cipher must be used.
<p>
<hr>
<h3><a name="ProxySFTPCompression">ProxySFTPCompression</a></h3>
<strong>Syntax:</strong> ProxySFTPCompression <em>on|off|delayed</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br>
<strong>Module:</strong> mod_proxy<br>
<strong>Compatibility:</strong> 1.3.8rc3 and later
<p>
The <code>ProxySFTPCompression</code> directive enables the use of zlib
compression of the payload of SSH2 packets. This can make for smaller packets,
but require more CPU time to compress/uncompress the data.
<p>
The <em>delayed</em> parameter tells <code>mod_proxy</code> to support a custom
extension used by OpenSSH, where compression is not actually enabled until
after the client has successfully authenticated.
<p>
<hr>
<h3><a name="ProxySFTPDigests">ProxySFTPDigests</a></h3>
<strong>Syntax:</strong> ProxySFTPDigests <em>algo1 ...</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br>
<strong>Module:</strong> mod_proxy<br>
<strong>Compatibility:</strong> 1.3.8rc3 and later
<p>
The <code>ProxySFTPDigests</code> directive is used to specify the list of
MAC digest algorithms that <code>mod_proxy</code> should use when connecting to
backend SSH servers. The current list of supported MAC algorithms is:
<ul>
<li>hmac-sha2-256
<li>hmac-sha2-512
<li>hmac-sha1
<li>hmac-sha1-96
</ul>
By default, all of the above MAC algorithms are presented to the server,
in the above order, during the key exchange. <b>Note</b> that some algorithms
(<i>e.g.</i> the SHA256 and SHA512 algorithms) may not be supported by
the version of OpenSSL used; this will be automatically detected.
<p>
The following list of algorithms are <em>supported</em>, but <b>not</b>
presented to servers by default. These algorithms must be <em>explicitly</em>
configured via <code>ProxySFTPDigests</code> to be available for use by servers:
<ul>
<li>hmac-md5
<li>hmac-md5-96
<li>hmac-ripemd160
</ul>
<p>
The "none" MAC (<i>i.e.</i> no MAC) will <b>not</b> be presented to the server
by default; any sites which wish to use "none" will have to explicitly
configure it via <code>ProxySFTPDigests</code>.
<p>
In general, there is no need to use this directive unless only one specific
MAC algorithm must be used.
<p>
<hr>
<h3><a name="ProxySFTPHostKey">ProxySFTPHostKey</a></h3>
<strong>Syntax:</strong> ProxySFTPHostKey <em>file</em>|agent:<em>/path</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br>
<strong>Module:</strong> mod_proxy<br>
<strong>Compatibility:</strong> 1.3.8rc3 and later
<p>
The <code>ProxySFTPHostKey</code> directive configures the path to a host key
file. The <code>mod_proxy</code> module uses the keys thus configured for
"hostbased" user authentication to backend SSH servers.
<p>
You can use either an RSA key, a DSA key, and/or ECDSA keys. These <i>could</i>
be the exact same host key files as used by your SSH server, <i>e.g.</i>:
<pre>
<IfModule mod_sftp.c>
...
SFTPHostKey /etc/ssh_host_dsa_key
SFTPHostKey /etc/ssh_host_rsa_key
SFTPHostKey /etc/ssh_host_ecdsa_key
SFTPHostKey /etc/ssh_host_ed25519_key
</IfModule>
<IfModule mod_proxy.c>
ProxyEngine on
..
ProxySFTPHostKey /etc/ssh_host_dsa_key
ProxySFTPHostKey /etc/ssh_host_rsa_key
ProxySFTPHostKey /etc/ssh_host_ecdsa_key
ProxySFTPHostKey /etc/ssh_host_ed25519_key
</IfModule>
</pre>