Debian Codegraph @

doc/howto/ServerType.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>ProFTPD: ServerType</title>
5 </head>
6
7 <body bgcolor=white>
8
9 <hr>
10 <center><h2><b><i>ServerType</i></b></h2></center>
11 <hr>
12
13 <p>
14 The <a href="../modules/mod_core.html#ServerType"><code>ServerType</code></a>
15 configuration directive for ProFTPD can cause confusion for those just starting
16 with this server. What is the purpose for this directive? What are these
17 &quot;inetd&quot; and &quot;standalone&quot; types, and why does one need to
18 choose one or the other?
19
20 <p>
21 The purpose of this directive is to choose between the two operating modes for
22 almost all Unix network servers: does the server listen on its port for
23 client requests itself, or does the server let some other process do the
24 listening, and call the server when needed? Traditionally, that
25 &quot;other process&quot; has been <code>inetd</code>, a
26 &quot;super server&quot; that listens on all interfaces, all ports on a
27 Unix machine, and calls the appropriate server based on the port contacted.
28 A more modern replacement for <code>inetd</code> is found in the
29 <code>xinetd</code> server; this server functions much the same way. The
30 other mode of operation is to have the server listen on the port(s) itself,
31 and handle client requests accordingly. The latter mode is the
32 <em>standalone</em> <code>ServerType</code>, the former is the <em>inetd</em>
33 mode (which covers both the <code>inetd</code> and <code>xinetd</code>
34 processes).
35
36 <p>
37 This directive is mandatory, and must be set to one mode or the other. The
38 two modes are incompatible (two processes cannot be bound to the same
39 interface/port combination simultaneously), and thus the <code>proftpd</code>
40 must be told in which mode it is to operate.
41
42 <p><a name="Inetd"></a>
43 <b>Inetd Mode</b><br>
44 In <em>inetd</em> mode, the <code>proftpd</code> server expects to be started
45 by the <code>inetd</code> (or <code>xinetd</code>) servers. It is these
46 servers, <code>inetd/xinetd</code>, that listen on the FTP port (usually 21)
47 for connection requests, then start <code>proftpd</code> and pass the
48 connection off. This mode is usually best suited for low traffic sites,
49 for sites that do not handle many FTP sessions.
50
51 <p>
52 Example <code>/etc/inetd.conf</code> entry:
53 <pre>
54 ftp stream tcp nowait root /usr/sbin/tcpd /usr/sbin/proftpd
55 </pre>
56 The <code>inetd.conf</code> man pages discuss these fields in greater detail.
57
58 <p>
59 An example <code>xinetd</code> configuration is:
60 <pre>
61 service ftp
62 {
63 disable = no
64 flags = IPv4
65 socket_type = stream
66 wait = no
67 user = root
68 server = /usr/sbin/proftpd
69 server_args = -c /etc/proftpd.conf
70 }
71 </pre>
72 The xinetd configuration is usually found in <code>/etc/xinetd.conf</code>
73 or in the <code>/etc/xinetd.d/</code> directory.
74
75 <p><a name="InetdIPv6"></a>
76 <b>Note</b>: Solaris users may find that their <code>/etc/inetd.conf</code>
77 file ships with an <code>ftp</code> entry that looks similar to the above,
78 except that it has &quot;tcp6&quot; rather than &quot;tcp&quot;. For
79 <code>proftpd</code> to function properly in such cases, that &quot;tcp6&quot;
80 will need to be changed to &quot;tcp&quot;. Solaris uses the <code>tcp6</code>
81 keyword to have its <code>inetd</code> pass IPv6 sockets to the called program;
82 <code>proftpd</code> must have been configured with the
83 <code>--enable-ipv6</code> option to handle such sockets.
84
85 <p><a name="InetdPorts"></a>
86 <b>Inetd Mode and Non-standard Ports</b><br>
87 A note about using non-standard ports in your configuration via the
88 <code>Port</code> configuration directive: making these work while in
89 <code>inetd</code> mode and using <code>inetd</code> (as oppposed to
90 <code>xinetd</code>) is problematic. The first column of an
91 <code>/etc/inetd.conf</code> entry lists a protocol name. The port
92 for that protocol is listed in the <code>/etc/services</code> file. For
93 services that run on non-standard ports, however,
94 <code>/etc/services</code> has no entry, and <code>inetd</code> is programmed
95 so as to always reference that file. This means that if use of non-standard
96 ports and use of <code>inetd</code> are required, the
97 <code>/etc/services</code> file will need to be edited. Avoid this situation
98 if possible.
99
100 <p>
101 Compared to <code>inetd</code>, <code>xinetd</code>'s configuration format
102 is more flexible: it can be configured to use non-standard ports using the
103 <code>port</code> attribute:
104 <pre>
105 port determines the service port. If this
106 attribute is specified for a service
107 listed in /etc/services, it must be equal
108 to the port number listed in that file.
109 </pre>
110 as described in the <code>xinetd.conf(5)</code> man page.
111
112 <p>
113 If your <code>proftpd</code> server is running in this mode, you do not need
114 to worry about restarting any servers whenever changes are made to the
115 <code>proftpd.conf</code> configuration file. Since <code>proftpd</code>
116 is started for each new FTP session by <code>inetd/xinetd</code>, and
117 part of that startup process includes reading the configuration file, any
118 changes will be seen by any new FTP sessions once the changes are made.
119
120 <p>
121 If you attempt to start a <code>proftpd</code> server configured with a
122 <code>ServerType</code> of <em>standalone</em>, and already have
123 <code>inetd/xinetd</code> also configured to handle FTP connections, this kind
124 of error message will appear in your <code>proftpd</code> logs:
125 <pre>
126 golem.castaglia.org - Failed binding to 127.0.0.1, port 21: Address already in use
127 golem.castaglia.org - Check the ServerType directive to ensure you are configured correctly.
128 </pre>
129 More information might be found by <a href="Debugging.html">debugging</a> your
130 configuration.
131
132 <p><a name="Standalone"></a>
133 <b>Standalone Mode</b><br>
134 In this mode, the <code>proftpd</code> listens for incoming FTP session
135 requests itself, and forks off child processes to handle those requests.
136 This mode is best suited for high traffic, popular sites; the overhead
137 of having to parse the configuration file each time, as is done for
138 <code>inetd</code>-handled sessions, is avoided in this mode. Also,
139 there is no need to change any other configuration files other than the
140 <code>proftpd.conf</code>, for ports, virtual servers, or anything else.
141
142 <p>
143 When running in this mode, the server will need to be restarted whenever
144 changes are made to the configuration file. There is a
145 <a href="Stopping.html">page</a> that describes how this can be done.
146
147 <p>
148 Many administrators are accustomed to using <code>tcpwrappers</code> to
149 secure their network servers; indeed, this is a good practice to get into.
150 However, the most common way this is done is through <code>inetd</code>.
151 When running a <code>proftpd</code> server in <em>standalone</em> mode,
152 then, it is not quite as straightforward; however, it is not hard, either.
153 The <a href="../contrib/mod_wrap.html"><code>mod_wrap</code></a> module can be
154 compiled into your <code>proftpd</code>. This module allows a standalone
155 <code>proftpd</code> server to use the normal <code>/etc/hosts.allow</code>,
156 <code>/etc/hosts.deny</code> files, in addition to other files (something that
157 normal <code>tcpwrappers</code> configurations cannot do).
158
159 <p>
160 If you try to start a <code>proftpd</code> server configured with a
161 <code>ServerType</code> of <em>inetd</em> from the command line (or from
162 some shell wrapper script), this kind of error message will appear in your
163 <code>proftpd</code> logs:
164 <pre>
165 golem.castaglia.org - Fatal: Socket operation on non-socket
166 golem.castaglia.org - (Running from command line? Use `ServerType standalone' in config file!)
167 </pre>
168 More information might be found by <a href="Debugging.html">debugging</a> your
169 configuration.
170
171 <p><a name="Switching">
172 <b>Switching Modes</b><br>
173 Changing from one <code>ServerType</code> mode to the other is a simple
174 process, as long as the few steps involved are followed.
175
176 <p>
177 To change from <em>inetd</em> to <em>standalone</em>, make sure to remove any
178 FTP configurations from <code>/etc/inetd.conf</code>,
179 <code>/etc/xinetd.conf</code>, <code>/etc/xinetd.d/</code>, or wherever
180 your superserver's configuration file(s) reside. Once this is done,
181 make sure those changes are seen by restarting <code>inetd/xinetd</code>.
182 Then, make sure
183 <pre>
184 ServerType standalone
185 </pre>
186 is in your <code>proftpd.conf</code>. Start the <code>proftpd</code>
187 server from the command line, to make sure all is working. You can then
188 easily start server from an <code>init.d</code> script such as the one
189 mentioned <a href="Stopping.html">here</a>.
190
191 <p>
192 To change from <em>standalone</em> to <em>inetd</em>, make sure your
193 <code>proftpd</code> is stopped completely. Add a configuration entry
194 for FTP into your <code>inetd/xinetd</code> configuration (mentioned
195 above), then restart <code>inetd/xinetd</code> to have those configuration
196 changes seen. Check your <code>proftpd.conf</code> to see that
197 <pre>
198 ServerType inetd
199 </pre>
200 is there.
201
202 <p><a name="FAQ">
203 <b>Frequently Asked Questions</b><br>
204
205 <font color=red>Question</font>: I have configured:
206 <pre>
207 &lt;IfModule mod_ident.c&gt;
208 IdentLookups off
209 &lt;/IfModule&gt;
210
211 ServerIdent off
212 </pre>
213 in my <code>proftpd.conf</code>, but my logins are still slow. Why?<br>
214 <font color=blue>Answer</font>: Another source of slow logins can be
215 <code>xinetd</code>, or <code>tcpwrappers</code> compiled for reverse DNS
216 lookups (<i>i.e.</i> with the <code>-DPARANOID</code> option).
217
218 <p>
219 If you are using <code>ServerType inetd</code>, <i>and</i> you are using
220 <code>xinetd</code> to run <code>proftpd</code>, then you should check your
221 <code>/etc/xinetd.conf</code> (or <code>/etc/xinetd.d/proftpd</code> or
222 similar) file for the <code>USERID</code> parameter, <i>e.g.</i>:
223 <pre>
224 log_on_success += DURATION USERID
225 log_on_failure += USERID
226 </pre>
227 As per the <code>xinetd.conf</code> documentation, the use of
228 <code>USERID</code> in your configuration causes <code>xinetd</code> to do
229 an IDENTD lookup:
230 <pre>
231 USERID logs the user id of the remote user using
232 the RFC 1413 identification protocol.
233 This option is available only for multi-
234 threaded stream services.
235 </pre>
236 Removing <code>USERID</code> from your <code>xinetd</code> configuration
237 for proftpd often suffices to fix the slow logins.
238
239 <p>
240 Another solution is simply to <a href="#Switching">switch</a> your
241 <code>ServerType</code> to "standalone".
242
243 <p>
244 <hr>
245 <font size=2><b><i>
246 &copy; Copyright 2017-2020 The ProFTPD Project<br>
247 All Rights Reserved<br>
248 </i></b></font>
249 <hr>
250
251 </body>
252 </html>