Fri Aug 24 11:43:13 2018 UTC ()
Bump date


(martin)
diff -r1.69 -r1.70 src/libexec/httpd/bozohttpd.8

cvs diff -r1.69 -r1.70 src/libexec/httpd/bozohttpd.8 (switch to unified diff)

--- src/libexec/httpd/bozohttpd.8 2018/08/24 11:41:16 1.69
+++ src/libexec/httpd/bozohttpd.8 2018/08/24 11:43:13 1.70
@@ -1,760 +1,760 @@ @@ -1,760 +1,760 @@
1.\" $NetBSD: bozohttpd.8,v 1.69 2018/08/24 11:41:16 martin Exp $ 1.\" $NetBSD: bozohttpd.8,v 1.70 2018/08/24 11:43:13 martin Exp $
2.\" 2.\"
3.\" $eterna: bozohttpd.8,v 1.101 2011/11/18 01:25:11 mrg Exp $ 3.\" $eterna: bozohttpd.8,v 1.101 2011/11/18 01:25:11 mrg Exp $
4.\" 4.\"
5.\" Copyright (c) 1997-2017 Matthew R. Green 5.\" Copyright (c) 1997-2017 Matthew R. Green
6.\" All rights reserved. 6.\" All rights reserved.
7.\" 7.\"
8.\" Redistribution and use in source and binary forms, with or without 8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions 9.\" modification, are permitted provided that the following conditions
10.\" are met: 10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright 11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer. 12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the 14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution. 15.\" documentation and/or other materials provided with the distribution.
16.\" 16.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27.\" SUCH DAMAGE. 27.\" SUCH DAMAGE.
28.\" 28.\"
29.Dd November 28, 2017 29.Dd August 24, 2018
30.Dt BOZOHTTPD 8 30.Dt BOZOHTTPD 8
31.Os 31.Os
32.Sh NAME 32.Sh NAME
33.Nm bozohttpd 33.Nm bozohttpd
34.Nd hyper text transfer protocol version 1.1 daemon 34.Nd hyper text transfer protocol version 1.1 daemon
35.Sh SYNOPSIS 35.Sh SYNOPSIS
36.Nm 36.Nm
37.Op Fl EGHVXefhnsu 37.Op Fl EGHVXefhnsu
38.Op Fl C Ar suffix cgihandler 38.Op Fl C Ar suffix cgihandler
39.Op Fl I Ar port 39.Op Fl I Ar port
40.Op Fl L Ar prefix script 40.Op Fl L Ar prefix script
41.Op Fl M Ar suffix type encoding encoding11 41.Op Fl M Ar suffix type encoding encoding11
42.Op Fl P Ar pidfile 42.Op Fl P Ar pidfile
43.Op Fl S Ar server_software 43.Op Fl S Ar server_software
44.Op Fl U Ar username 44.Op Fl U Ar username
45.Op Fl Z Ar cert privkey 45.Op Fl Z Ar cert privkey
46.Op Fl c Ar cgibin 46.Op Fl c Ar cgibin
47.Op Fl i Ar address 47.Op Fl i Ar address
48.Op Fl p Ar pubdir 48.Op Fl p Ar pubdir
49.Op Fl t Ar chrootdir 49.Op Fl t Ar chrootdir
50.Op Fl v Ar virtualroot 50.Op Fl v Ar virtualroot
51.Op Fl x Ar index 51.Op Fl x Ar index
52.Op Fl z Ar ciphers 52.Op Fl z Ar ciphers
53.Ar slashdir 53.Ar slashdir
54.Op Ar myname 54.Op Ar myname
55.Sh DESCRIPTION 55.Sh DESCRIPTION
56The 56The
57.Nm 57.Nm
58program reads a 58program reads a
59.Em HTTP 59.Em HTTP
60request from the standard input, and sends a reply to the standard output. 60request from the standard input, and sends a reply to the standard output.
61Besides ~user translation and virtual hosting support (see below), all file 61Besides ~user translation and virtual hosting support (see below), all file
62requests are from 62requests are from
63.Ar slashdir 63.Ar slashdir
64directory. 64directory.
65The server uses 65The server uses
66.Ar myname 66.Ar myname
67as its name, which defaults to the local hostname, obtained from 67as its name, which defaults to the local hostname, obtained from
68.Xr gethostname 3 68.Xr gethostname 3
69(but see the 69(but see the
70.Fl v 70.Fl v
71option for virtual hosting.) 71option for virtual hosting.)
72.Nm 72.Nm
73writes logs to 73writes logs to
74.Xr syslog 3 74.Xr syslog 3
75using the ftp facility (but see the 75using the ftp facility (but see the
76.Fl s 76.Fl s
77option for testing.) 77option for testing.)
78.Nm 78.Nm
79is designed to be small, simple and relatively featureless, 79is designed to be small, simple and relatively featureless,
80hopefully increasing its security. 80hopefully increasing its security.
81.Ss OPTIONS 81.Ss OPTIONS
82The following options are available: 82The following options are available:
83.Bl -tag -width xxxcgibin 83.Bl -tag -width xxxcgibin
84.It Fl b 84.It Fl b
85Enables daemon mode, where 85Enables daemon mode, where
86.Nm 86.Nm
87detaches from the current terminal, running in the background and 87detaches from the current terminal, running in the background and
88servicing HTTP requests. 88servicing HTTP requests.
89.It Fl C Ar suffix cgihandler 89.It Fl C Ar suffix cgihandler
90Adds a new CGI handler program for a particular file type. 90Adds a new CGI handler program for a particular file type.
91The 91The
92.Ar suffix 92.Ar suffix
93should be any normal file suffix, and the 93should be any normal file suffix, and the
94.Ar cgihandler 94.Ar cgihandler
95should be a full path to an interpreter. 95should be a full path to an interpreter.
96This option is the only way to enable CGI programs that exist 96This option is the only way to enable CGI programs that exist
97outside of the cgibin directory to be executed. 97outside of the cgibin directory to be executed.
98Multiple 98Multiple
99.Fl C 99.Fl C
100options may be passed. 100options may be passed.
101.It Fl c Ar cgibin 101.It Fl c Ar cgibin
102Enables the CGI/1.1 interface. 102Enables the CGI/1.1 interface.
103The 103The
104.Ar cgibin 104.Ar cgibin
105directory is expected to contain the CGI programs to be used. 105directory is expected to contain the CGI programs to be used.
106.Nm 106.Nm
107looks for URL's in the form of 107looks for URL's in the form of
108.Em /cgi-bin/<scriptname> 108.Em /cgi-bin/<scriptname>
109where 109where
110.Aq scriptname 110.Aq scriptname
111is a valid CGI program in the 111is a valid CGI program in the
112.Ar cgibin 112.Ar cgibin
113directory. 113directory.
114In other words, all CGI URL's must begin with 114In other words, all CGI URL's must begin with
115.Em \%/cgi-bin/ . 115.Em \%/cgi-bin/ .
116Note that the CGI/1.1 interface is available with 116Note that the CGI/1.1 interface is available with
117.Em ~user 117.Em ~user
118translation using 118translation using
119.Fl E 119.Fl E
120switch. 120switch.
121.It Fl e 121.It Fl e
122Causes 122Causes
123.Nm 123.Nm
124to not clear the environment when used with either the 124to not clear the environment when used with either the
125.Fl t 125.Fl t
126or 126or
127.Fl U 127.Fl U
128options. 128options.
129.It Fl f 129.It Fl f
130Stops the 130Stops the
131.Fl b 131.Fl b
132flag from 132flag from
133.Nm 133.Nm
134detaching from the tty and going into the background. 134detaching from the tty and going into the background.
135.It Fl G 135.It Fl G
136Get the 136Get the
137.Nm 137.Nm
138version string, print it on standard output, and exit. 138version string, print it on standard output, and exit.
139.It Fl H 139.It Fl H
140Causes directory index mode to hide files and directories 140Causes directory index mode to hide files and directories
141that start with a period, except for 141that start with a period, except for
142.Pa .. . 142.Pa .. .
143Also see 143Also see
144.Fl X . 144.Fl X .
145.It Fl I Ar port 145.It Fl I Ar port
146Causes 146Causes
147.Nm 147.Nm
148to use 148to use
149.Ar port 149.Ar port
150instead of the default 150instead of the default
151.Dq http 151.Dq http
152port. 152port.
153When used with the 153When used with the
154.Fl b 154.Fl b
155option, it changes the bound port. 155option, it changes the bound port.
156Otherwise it forces redirections to use this port instead of the 156Otherwise it forces redirections to use this port instead of the
157value obtained via 157value obtained via
158.Xr getsockname 2 . 158.Xr getsockname 2 .
159.It Fl i Ar address 159.It Fl i Ar address
160Causes 160Causes
161.Ar address 161.Ar address
162to be used as the address to bind daemon mode. 162to be used as the address to bind daemon mode.
163If otherwise unspecified, the address used to bind is derived from the 163If otherwise unspecified, the address used to bind is derived from the
164.Ar myname , 164.Ar myname ,
165which defaults to the name returned by 165which defaults to the name returned by
166.Xr gethostname 3 . 166.Xr gethostname 3 .
167Only the last 167Only the last
168.Fl i 168.Fl i
169option is used. 169option is used.
170This option is only valid with the 170This option is only valid with the
171.Fl b 171.Fl b
172option. 172option.
173.It Fl L Ar prefix script 173.It Fl L Ar prefix script
174Adds a new Lua script for a particular prefix. 174Adds a new Lua script for a particular prefix.
175The 175The
176.Ar prefix 176.Ar prefix
177should be an arbitrary text, and the 177should be an arbitrary text, and the
178.Ar script 178.Ar script
179should be a full path to a Lua script. 179should be a full path to a Lua script.
180Multiple 180Multiple
181.Fl L 181.Fl L
182options may be passed. 182options may be passed.
183A separate Lua state is created for each prefix. 183A separate Lua state is created for each prefix.
184The Lua script can register callbacks using the 184The Lua script can register callbacks using the
185httpd.register_handler('<name>', function) Lua function, 185httpd.register_handler('<name>', function) Lua function,
186which will trigger the execution of the Lua function 186which will trigger the execution of the Lua function
187.Em function 187.Em function
188when a URL in the form 188when a URL in the form
189.Em http://<hostname>/<prefix>/<name> 189.Em http://<hostname>/<prefix>/<name>
190is being accessed. 190is being accessed.
191The function is passed three tables as arguments, the server 191The function is passed three tables as arguments, the server
192environment, the request headers, and the decoded query string 192environment, the request headers, and the decoded query string
193plus any data that was sent as application/x-www-form-urlencoded. 193plus any data that was sent as application/x-www-form-urlencoded.
194.It Fl M Ar suffix type encoding encoding11 194.It Fl M Ar suffix type encoding encoding11
195Adds a new entry to the table that converts file suffixes to 195Adds a new entry to the table that converts file suffixes to
196content type and encoding. 196content type and encoding.
197This option takes four additional arguments containing 197This option takes four additional arguments containing
198the file prefix, its 198the file prefix, its
199.Dq Content-Type , 199.Dq Content-Type ,
200.Dq Content-Encoding , 200.Dq Content-Encoding ,
201and 201and
202.Dq Content-Encoding 202.Dq Content-Encoding
203for HTTP/1.1 connections, respectively. 203for HTTP/1.1 connections, respectively.
204If any of these are a single dash 204If any of these are a single dash
205.Pq Dq - , 205.Pq Dq - ,
206the empty string is used instead. 206the empty string is used instead.
207Multiple 207Multiple
208.Fl M 208.Fl M
209options may be passed. 209options may be passed.
210.It Fl n 210.It Fl n
211Stops 211Stops
212.Nm 212.Nm
213from doing IP address to name resolution of hosts for setting the 213from doing IP address to name resolution of hosts for setting the
214.Ev REMOTE_HOST 214.Ev REMOTE_HOST
215variable before running a CGI program. 215variable before running a CGI program.
216This option has no effect without the 216This option has no effect without the
217.Fl c 217.Fl c
218option. 218option.
219.It Fl P Ar pidfile 219.It Fl P Ar pidfile
220Causes 220Causes
221.Nm 221.Nm
222to create a PID file in 222to create a PID file in
223.Ar pidfile 223.Ar pidfile
224when run in daemon mode with the 224when run in daemon mode with the
225.Fl b 225.Fl b
226option. 226option.
227.It Fl p Ar pubdir 227.It Fl p Ar pubdir
228Changes the default user directory for 228Changes the default user directory for
229.Em /~user/ 229.Em /~user/
230translations from 230translations from
231.Dq public_html 231.Dq public_html
232to 232to
233.Ar pubdir . 233.Ar pubdir .
234.It Fl S Ar server_software 234.It Fl S Ar server_software
235Sets the internal server version to 235Sets the internal server version to
236.Ar server_software . 236.Ar server_software .
237.It Fl s 237.It Fl s
238Forces logging to be set to stderr always. 238Forces logging to be set to stderr always.
239.It Fl t Ar chrootdir 239.It Fl t Ar chrootdir
240Makes 240Makes
241.Nm 241.Nm
242chroot to the specified directory 242chroot to the specified directory
243before answering requests. 243before answering requests.
244Every other path should be specified relative 244Every other path should be specified relative
245to the new root, if this option is used. 245to the new root, if this option is used.
246Note that the current environment 246Note that the current environment
247is normally replaced with an empty environment with this option, unless the 247is normally replaced with an empty environment with this option, unless the
248.Fl e 248.Fl e
249option is also used. 249option is also used.
250.It Fl U Ar username 250.It Fl U Ar username
251Causes 251Causes
252.Nm 252.Nm
253to switch to the user and the groups of 253to switch to the user and the groups of
254.Ar username 254.Ar username
255after initialization. 255after initialization.
256This option, like 256This option, like
257.Fl t 257.Fl t
258above, causes 258above, causes
259.Nm 259.Nm
260to clear the environment unless the 260to clear the environment unless the
261.Fl e 261.Fl e
262option is given. 262option is given.
263.It Fl u 263.It Fl u
264Enables the transformation of Uniform Resource Locators of 264Enables the transformation of Uniform Resource Locators of
265the form 265the form
266.Em /~user/ 266.Em /~user/
267into the directory 267into the directory
268.Pa ~user/public_html 268.Pa ~user/public_html
269(but see the 269(but see the
270.Fl p 270.Fl p
271option above). 271option above).
272.It Fl E 272.It Fl E
273Enables CGI/1.1 interface for 273Enables CGI/1.1 interface for
274.Em ~user 274.Em ~user
275translation. 275translation.
276Note that enabling this support implies that users can run 276Note that enabling this support implies that users can run
277commands as web server user, this may have security implications. 277commands as web server user, this may have security implications.
278.It Fl V 278.It Fl V
279Sets the backup virtual host directory to the 279Sets the backup virtual host directory to the
280.Ar slashdir 280.Ar slashdir
281argument. 281argument.
282If no directory exists in 282If no directory exists in
283.Ar virtualroot 283.Ar virtualroot
284for the request, then 284for the request, then
285.Ar slashdir 285.Ar slashdir
286will be used. 286will be used.
287The default behavior is to return 404 (Not Found.) 287The default behavior is to return 404 (Not Found.)
288.It Fl v Ar virtualroot 288.It Fl v Ar virtualroot
289Enables virtual hosting support. 289Enables virtual hosting support.
290Directories in 290Directories in
291.Ar virtualroot 291.Ar virtualroot
292will be searched for a matching virtual host name, when parsing 292will be searched for a matching virtual host name, when parsing
293the HTML request. 293the HTML request.
294If a matching name is found, it will be used 294If a matching name is found, it will be used
295as both the server's real name, 295as both the server's real name,
296.Op Ar myname , 296.Op Ar myname ,
297and as the 297and as the
298.Ar slashdir . 298.Ar slashdir .
299See the 299See the
300.Sx EXAMPLES 300.Sx EXAMPLES
301section for an example of using this option. 301section for an example of using this option.
302.It Fl X 302.It Fl X
303Enables directory indexing. 303Enables directory indexing.
304A directory index will be generated only when the default file (i.e. 304A directory index will be generated only when the default file (i.e.
305.Pa index.html 305.Pa index.html
306normally) is not present. 306normally) is not present.
307.It Fl x Ar index 307.It Fl x Ar index
308Changes the default file read for directories from 308Changes the default file read for directories from
309.Dq index.html 309.Dq index.html
310to 310to
311.Ar index . 311.Ar index .
312.It Fl z Ar ciphers 312.It Fl z Ar ciphers
313Sets the list of SSL ciphers (see 313Sets the list of SSL ciphers (see
314.Xr SSL_CTX_set_cipher_list 3 ) . 314.Xr SSL_CTX_set_cipher_list 3 ) .
315.It Fl Z Ar certificate_path privatekey_path 315.It Fl Z Ar certificate_path privatekey_path
316Sets the path to the server certificate file and the private key file 316Sets the path to the server certificate file and the private key file
317in PEM format. 317in PEM format.
318It also causes 318It also causes
319.Nm 319.Nm
320to start SSL mode. 320to start SSL mode.
321.El 321.El
322.Pp 322.Pp
323Note that in 323Note that in
324.Nm 324.Nm
325versions 20031005 and prior that supported the 325versions 20031005 and prior that supported the
326.Fl C 326.Fl C
327and 327and
328.Fl M 328.Fl M
329options, they took a single space-separated argument that was parsed. 329options, they took a single space-separated argument that was parsed.
330since version 20040828, they take multiple options (2 in the case of 330since version 20040828, they take multiple options (2 in the case of
331.Fl C 331.Fl C
332and 4 in the case of 332and 4 in the case of
333.Fl M . ) 333.Fl M . )
334.Ss INETD CONFIGURATION 334.Ss INETD CONFIGURATION
335As 335As
336.Nm 336.Nm
337uses 337uses
338.Xr inetd 8 338.Xr inetd 8
339by default to process incoming TCP connections for HTTP requests 339by default to process incoming TCP connections for HTTP requests
340(but see the 340(but see the
341.Fl b 341.Fl b
342option), 342option),
343.Nm 343.Nm
344has little internal networking knowledge. 344has little internal networking knowledge.
345(Indeed, you can run it on the command line with little change of 345(Indeed, you can run it on the command line with little change of
346functionality.) 346functionality.)
347A typical 347A typical
348.Xr inetd.conf 5 348.Xr inetd.conf 5
349entry would be: 349entry would be:
350.Bd -literal 350.Bd -literal
351http stream tcp nowait:600 _httpd /usr/libexec/httpd httpd /var/www 351http stream tcp nowait:600 _httpd /usr/libexec/httpd httpd /var/www
352http stream tcp6 nowait:600 _httpd /usr/libexec/httpd httpd /var/www 352http stream tcp6 nowait:600 _httpd /usr/libexec/httpd httpd /var/www
353.Ed 353.Ed
354.Pp 354.Pp
355This would serve web pages from 355This would serve web pages from
356.Pa /var/www 356.Pa /var/www
357on both IPv4 and IPv6 ports. 357on both IPv4 and IPv6 ports.
358The 358The
359.Em :600 359.Em :600
360changes the 360changes the
361requests per minute to 600, up from the 361requests per minute to 600, up from the
362.Xr inetd 8 362.Xr inetd 8
363default of 40. 363default of 40.
364.Pp 364.Pp
365Using the 365Using the
366.Nx 366.Nx
367.Xr inetd 8 , 367.Xr inetd 8 ,
368you can provide multiple IP-address based HTTP servers by having multiple 368you can provide multiple IP-address based HTTP servers by having multiple
369listening ports with different configurations. 369listening ports with different configurations.
370.Ss NOTES 370.Ss NOTES
371This server supports the 371This server supports the
372.Em HTTP/0.9 , 372.Em HTTP/0.9 ,
373.Em HTTP/1.0 , 373.Em HTTP/1.0 ,
374and 374and
375.Em HTTP/1.1 375.Em HTTP/1.1
376standards. 376standards.
377Support for these protocols is very minimal and many optional features are 377Support for these protocols is very minimal and many optional features are
378not supported. 378not supported.
379.Pp 379.Pp
380.Nm 380.Nm
381can be compiled without 381can be compiled without
382CGI support (NO_CGIBIN_SUPPORT), 382CGI support (NO_CGIBIN_SUPPORT),
383user transformations (NO_USER_SUPPORT), 383user transformations (NO_USER_SUPPORT),
384directory index support (NO_DIRINDEX_SUPPORT), 384directory index support (NO_DIRINDEX_SUPPORT),
385daemon mode support (NO_DAEMON_MODE), 385daemon mode support (NO_DAEMON_MODE),
386dynamic MIME content (NO_DYNAMIC_CONTENT), 386dynamic MIME content (NO_DYNAMIC_CONTENT),
387Lua support (NO_LUA_SUPPORT), 387Lua support (NO_LUA_SUPPORT),
388and SSL support (NO_SSL_SUPPORT) 388and SSL support (NO_SSL_SUPPORT)
389by defining the listed macros when building 389by defining the listed macros when building
390.Nm . 390.Nm .
391.Ss HTTP BASIC AUTHORIZATION 391.Ss HTTP BASIC AUTHORIZATION
392.Nm 392.Nm
393has support for HTTP Basic Authorization. 393has support for HTTP Basic Authorization.
394If a file named 394If a file named
395.Pa .htpasswd 395.Pa .htpasswd
396exists in the directory of the current request, 396exists in the directory of the current request,
397.Nm 397.Nm
398will restrict access to documents in that directory 398will restrict access to documents in that directory
399using the RFC 2617 HTTP 399using the RFC 2617 HTTP
400.Dq Basic 400.Dq Basic
401authentication scheme. 401authentication scheme.
402.Pp 402.Pp
403Note: 403Note:
404This does not recursively protect any sub-directories. 404This does not recursively protect any sub-directories.
405.Pp 405.Pp
406The 406The
407.Pa .htpasswd 407.Pa .htpasswd
408file contains lines delimited with a colon containing 408file contains lines delimited with a colon containing
409user names and passwords hashed with 409user names and passwords hashed with
410.Xr crypt 3 , 410.Xr crypt 3 ,
411for example: 411for example:
412.Bd -literal 412.Bd -literal
413heather:$1$pZWI4tH/$DzDPl63i6VvVRv2lJNV7k1 413heather:$1$pZWI4tH/$DzDPl63i6VvVRv2lJNV7k1
414jeremy:A.xewbx2DpQ8I 414jeremy:A.xewbx2DpQ8I
415.Ed 415.Ed
416.Pp 416.Pp
417On 417On
418.Nx , 418.Nx ,
419the 419the
420.Xr pwhash 1 420.Xr pwhash 1
421utility may be used to generate hashed passwords. 421utility may be used to generate hashed passwords.
422.Pp 422.Pp
423While 423While
424.Nm 424.Nm
425distributed with 425distributed with
426.Nx 426.Nx
427has support for HTTP Basic Authorization enabled by default, 427has support for HTTP Basic Authorization enabled by default,
428in the portable distribution it is excluded. 428in the portable distribution it is excluded.
429Compile 429Compile
430.Nm 430.Nm
431with 431with
432.Dq -DDO_HTPASSWD 432.Dq -DDO_HTPASSWD
433on the compiler command line to enable this support. 433on the compiler command line to enable this support.
434It may require linking with the crypt library, using 434It may require linking with the crypt library, using
435.Dq -lcrypt . 435.Dq -lcrypt .
436.Ss SSL SUPPORT 436.Ss SSL SUPPORT
437.Nm 437.Nm
438has support for TLSv1.1 and TLSv1.2 protocols that are included by 438has support for TLSv1.1 and TLSv1.2 protocols that are included by
439default. 439default.
440It requires linking with the crypto and ssl library, using 440It requires linking with the crypto and ssl library, using
441.Dq -lcrypto -lssl . 441.Dq -lcrypto -lssl .
442To disable SSL SUPPORT compile 442To disable SSL SUPPORT compile
443.Nm 443.Nm
444with 444with
445.Dq -DNO_SSL_SUPPORT 445.Dq -DNO_SSL_SUPPORT
446on the compiler command line. 446on the compiler command line.
447.Ss COMPRESSION 447.Ss COMPRESSION
448.Nm 448.Nm
449supports a very basic form of compression. 449supports a very basic form of compression.
450.Nm 450.Nm
451will serve the requested file postpended with 451will serve the requested file postpended with
452.Dq Pa .gz 452.Dq Pa .gz
453if it exists, it is readable, the client requested gzip compression, and 453if it exists, it is readable, the client requested gzip compression, and
454the client did not make a ranged request. 454the client did not make a ranged request.
455.Sh FILES 455.Sh FILES
456.Nm 456.Nm
457looks for a couple of special files in directories that allow certain features 457looks for a couple of special files in directories that allow certain features
458to be provided on a per-directory basis. 458to be provided on a per-directory basis.
459In addition to the 459In addition to the
460.Pa .htpasswd 460.Pa .htpasswd
461used by HTTP basic authorization, 461used by HTTP basic authorization,
462if a 462if a
463.Pa .bzdirect 463.Pa .bzdirect
464file is found (contents are irrelevant) 464file is found (contents are irrelevant)
465.Nm 465.Nm
466will allow direct access even with the 466will allow direct access even with the
467.Fl r 467.Fl r
468option. 468option.
469If a 469If a
470.Pa .bzredirect 470.Pa .bzredirect
471symbolic link is found, 471symbolic link is found,
472.Nm 472.Nm
473will perform a smart redirect to the target of this symlink. 473will perform a smart redirect to the target of this symlink.
474The target is assumed to live on the same server. 474The target is assumed to live on the same server.
475If target starts with slash then absolute redirection is performed, 475If target starts with slash then absolute redirection is performed,
476otherwise it's handled as relative. 476otherwise it's handled as relative.
477If a 477If a
478.Pa .bzabsredirect 478.Pa .bzabsredirect
479symbolic link is found, 479symbolic link is found,
480.Nm 480.Nm
481will redirect to the absolute URL pointed to by this symlink. 481will redirect to the absolute URL pointed to by this symlink.
482This is useful to redirect to different servers. 482This is useful to redirect to different servers.
483Two forms of redirection are supported - symbolic link without schema will use 483Two forms of redirection are supported - symbolic link without schema will use
484.Em http:// 484.Em http://
485as default i.e. link to 485as default i.e. link to
486.Em NetBSD.org 486.Em NetBSD.org
487will redirect to 487will redirect to
488.Em http://NetBSD.org/ 488.Em http://NetBSD.org/
489Otherwise provided schema will be used i.e. symbolic link to 489Otherwise provided schema will be used i.e. symbolic link to
490.Em ftp://NetBSD.org/ 490.Em ftp://NetBSD.org/
491will redirect to the provided URL. 491will redirect to the provided URL.
492If a 492If a
493.Pa .bzremap 493.Pa .bzremap
494file is found at the root of a (virtual) server, it is expected to contain 494file is found at the root of a (virtual) server, it is expected to contain
495rewrite mappings for URLs. 495rewrite mappings for URLs.
496.Pp 496.Pp
497These remappings are performed internally in the server before authentication 497These remappings are performed internally in the server before authentication
498happens and can be used to hide implementation details, like the CGI handler 498happens and can be used to hide implementation details, like the CGI handler
499specific suffix for non cgi scripts in authorized directories. 499specific suffix for non cgi scripts in authorized directories.
500.Pp 500.Pp
501The map file consists of lines two paths separated by a colon, where the left 501The map file consists of lines two paths separated by a colon, where the left
502side needs to exactly match a (sub) path of the request and will be replaced 502side needs to exactly match a (sub) path of the request and will be replaced
503by the right side. 503by the right side.
504.Pp 504.Pp
505The first match always wins. 505The first match always wins.
506.Pp 506.Pp
507A 507A
508.Pa .bzremap 508.Pa .bzremap
509file could look like this: 509file could look like this:
510.Bd -literal 510.Bd -literal
511/nic/update:/auth-dir/updipv4.pl 511/nic/update:/auth-dir/updipv4.pl
512.Ed 512.Ed
513.Pp 513.Pp
514The remap file should be short, access to it is slow and needs to happen 514The remap file should be short, access to it is slow and needs to happen
515on each request. 515on each request.
516If a request path needs to include a colon  516If a request path needs to include a colon
517.Pq Li \&: 517.Pq Li \&:
518character, it can be escaped 518character, it can be escaped
519with a backslash 519with a backslash
520.Pq Li \e 520.Pq Li \e
521The right hand side of the colon is always used verbatim, no escape sequences 521The right hand side of the colon is always used verbatim, no escape sequences
522are interpreted. 522are interpreted.
523.Sh EXAMPLES 523.Sh EXAMPLES
524To configure set of virtual hosts, one would use an 524To configure set of virtual hosts, one would use an
525.Xr inetd.conf 5 525.Xr inetd.conf 5
526entry like: 526entry like:
527.Bd -literal 527.Bd -literal
528http stream tcp nowait:600 _httpd /usr/libexec/httpd httpd -v /var/vroot /var/www 528http stream tcp nowait:600 _httpd /usr/libexec/httpd httpd -v /var/vroot /var/www
529.Ed 529.Ed
530.Pp 530.Pp
531and inside 531and inside
532.Pa /var/vroot 532.Pa /var/vroot
533create a directory (or a symlink to a directory) with the same name as 533create a directory (or a symlink to a directory) with the same name as
534the virtual host, for each virtual host. 534the virtual host, for each virtual host.
535Lookups for these names are done in a case-insensitive manner, and may 535Lookups for these names are done in a case-insensitive manner, and may
536include the port number part of the request, allowing for distinct 536include the port number part of the request, allowing for distinct
537virtual hosts on the same name. 537virtual hosts on the same name.
538.Pp 538.Pp
539To use 539To use
540.Nm 540.Nm
541with PHP, one must use the 541with PHP, one must use the
542.Fl C 542.Fl C
543option to specify a CGI handler for a particular file type. 543option to specify a CGI handler for a particular file type.
544Typically this will be like: 544Typically this will be like:
545.Bd -literal 545.Bd -literal
546httpd -C .php /usr/pkg/bin/php-cgi /var/www 546httpd -C .php /usr/pkg/bin/php-cgi /var/www
547.Ed 547.Ed
548.Pp 548.Pp
549Note that a plain script interpreter can not be used directly as a cgihandler, 549Note that a plain script interpreter can not be used directly as a cgihandler,
550as there are no command line options passed from 550as there are no command line options passed from
551.Nm 551.Nm
552to avoid security issues. 552to avoid security issues.
553.Pp 553.Pp
554If no CGI-aware wrapper exists, a simple shell script like the following 554If no CGI-aware wrapper exists, a simple shell script like the following
555might do. 555might do.
556.Pp 556.Pp
557It would be invoked like: 557It would be invoked like:
558.Bd -literal 558.Bd -literal
559httpd -C .pl /www-scripts/bin/run.perl /var/www 559httpd -C .pl /www-scripts/bin/run.perl /var/www
560.Ed 560.Ed
561and the script could look like: 561and the script could look like:
562.Bd -literal 562.Bd -literal
563#! /bin/sh 563#! /bin/sh
564 564
565if [ -r "$SCRIPT_FILENAME" -a -x "$SCRIPT_FILENAME" ]; then 565if [ -r "$SCRIPT_FILENAME" -a -x "$SCRIPT_FILENAME" ]; then
566 exec /usr/pkg/bin/perl "$SCRIPT_FILENAME" 566 exec /usr/pkg/bin/perl "$SCRIPT_FILENAME"
567fi 567fi
568 568
569exit 1 569exit 1
570.Ed 570.Ed
571.Sh SEE ALSO 571.Sh SEE ALSO
572.Xr inetd.conf 5 , 572.Xr inetd.conf 5 ,
573.Xr inetd 8 573.Xr inetd 8
574.Sh HISTORY 574.Sh HISTORY
575.Nm 575.Nm
576was first written in perl, based on another perl http server 576was first written in perl, based on another perl http server
577called 577called
578.Dq tinyhttpd . 578.Dq tinyhttpd .
579It was then rewritten from scratch in perl, and then once again in C. 579It was then rewritten from scratch in perl, and then once again in C.
580From 580From
581.Dq bozohttpd 581.Dq bozohttpd
582version 20060517, it has been integrated into 582version 20060517, it has been integrated into
583.Nx . 583.Nx .
584The focus has always been simplicity and security, with minimal features 584The focus has always been simplicity and security, with minimal features
585and regular code audits. 585and regular code audits.
586This manual documents 586This manual documents
587.Nm 587.Nm
588version 20180824. 588version 20180824.
589.Sh AUTHORS 589.Sh AUTHORS
590.An -nosplit 590.An -nosplit
591.Nm 591.Nm
592was written by 592was written by
593.An Matthew R. Green 593.An Matthew R. Green
594.Aq Mt mrg@eterna.com.au . 594.Aq Mt mrg@eterna.com.au .
595.Pp 595.Pp
596The large list of contributors includes: 596The large list of contributors includes:
597.Bl -dash 597.Bl -dash
598.It 598.It
599.An Marc Balmer 599.An Marc Balmer
600.Aq Mt mbalmer@NetBSD.org 600.Aq Mt mbalmer@NetBSD.org
601added Lua support for dynamic content creation 601added Lua support for dynamic content creation
602.It 602.It
603.An Christoph Badura 603.An Christoph Badura
604.Aq Mt bad@bsd.de 604.Aq Mt bad@bsd.de
605provided Range: header support 605provided Range: header support
606.It 606.It
607.An Sean Boudreau 607.An Sean Boudreau
608.Aq Mt seanb@NetBSD.org 608.Aq Mt seanb@NetBSD.org
609provided a security fix for virtual hosting 609provided a security fix for virtual hosting
610.It 610.It
611.An Julian Coleman 611.An Julian Coleman
612.Aq Mt jdc@coris.org.uk 612.Aq Mt jdc@coris.org.uk
613provided an IPv6 bugfix 613provided an IPv6 bugfix
614.It 614.It
615.An Chuck Cranor 615.An Chuck Cranor
616.Aq Mt chuck@research.att.com 616.Aq Mt chuck@research.att.com
617provided cgi-bin support fixes, and more 617provided cgi-bin support fixes, and more
618.It 618.It
619.An Alistair G. Crooks 619.An Alistair G. Crooks
620.Aq Mt agc@NetBSD.org 620.Aq Mt agc@NetBSD.org
621cleaned up many internal interfaces, made 621cleaned up many internal interfaces, made
622.Nm 622.Nm
623linkable as a library and provided the Lua binding. 623linkable as a library and provided the Lua binding.
624.It 624.It
625.An DEGROOTE Arnaud 625.An DEGROOTE Arnaud
626.Aq Mt degroote@NetBSD.org 626.Aq Mt degroote@NetBSD.org
627provided a fix for daemon mode 627provided a fix for daemon mode
628.It 628.It
629.An Andrew Doran 629.An Andrew Doran
630.Aq Mt ad@NetBSD.org 630.Aq Mt ad@NetBSD.org
631provided directory indexing support 631provided directory indexing support
632.It 632.It
633.An Per Ekman 633.An Per Ekman
634.Aq Mt pek@pdc.kth.se 634.Aq Mt pek@pdc.kth.se
635provided a fix for a minor (non-security) buffer overflow condition 635provided a fix for a minor (non-security) buffer overflow condition
636.It 636.It
637.An Roland Dowdeswell 637.An Roland Dowdeswell
638.Aq Mt elric@NetBSD.org 638.Aq Mt elric@NetBSD.org
639added support for serving gzipped files and better SSL handling 639added support for serving gzipped files and better SSL handling
640.It 640.It
641.An Jun-ichiro itojun Hagino, KAME 641.An Jun-ichiro itojun Hagino, KAME
642.Aq Mt itojun@iijlab.net 642.Aq Mt itojun@iijlab.net
643provided initial IPv6 support 643provided initial IPv6 support
644.It 644.It
645.An Martin Husemann 645.An Martin Husemann
646.Aq Mt martin@NetBSD.org 646.Aq Mt martin@NetBSD.org
647provided .bzabsredirect support, and fixed various redirection issues 647provided .bzabsredirect support, and fixed various redirection issues
648.It 648.It
649.An Arto Huusko 649.An Arto Huusko
650.Aq Mt arto.huusko@pp2.inet.fi 650.Aq Mt arto.huusko@pp2.inet.fi
651provided fixes cgi-bin 651provided fixes cgi-bin
652.It 652.It
653.An Roland Illig 653.An Roland Illig
654.Aq Mt roland.illig@gmx.de 654.Aq Mt roland.illig@gmx.de
655provided some off-by-one fixes 655provided some off-by-one fixes
656.It 656.It
657.An Zak Johnson 657.An Zak Johnson
658.Aq Mt zakj@nox.cx 658.Aq Mt zakj@nox.cx
659provided cgi-bin enhancements 659provided cgi-bin enhancements
660.It 660.It
661.An Nicolas Jombart 661.An Nicolas Jombart
662.Aq Mt ecu@ipv42.net 662.Aq Mt ecu@ipv42.net
663provided fixes for HTTP basic authorization support 663provided fixes for HTTP basic authorization support
664.It 664.It
665.An Antti Kantee 665.An Antti Kantee
666.Aq Mt pooka@NetBSD.org 666.Aq Mt pooka@NetBSD.org
667provided fixes for HTTP basic authorization support 667provided fixes for HTTP basic authorization support
668.It 668.It
669.An Thomas Klausner 669.An Thomas Klausner
670.Aq Mt wiz@NetBSD.org 670.Aq Mt wiz@NetBSD.org
671provided many fixes and enhancements for the man page 671provided many fixes and enhancements for the man page
672.It 672.It
673.An Mateusz Kocielski 673.An Mateusz Kocielski
674.Aq Mt shm@NetBSD.org 674.Aq Mt shm@NetBSD.org
675fixed memory leaks, various issues with userdir support, 675fixed memory leaks, various issues with userdir support,
676information disclosure issues, added support for using CGI handlers 676information disclosure issues, added support for using CGI handlers
677with directory indexing, found several security issues and provided 677with directory indexing, found several security issues and provided
678various other fixes. 678various other fixes.
679.It 679.It
680.An Arnaud Lacombe 680.An Arnaud Lacombe
681.Aq Mt alc@NetBSD.org 681.Aq Mt alc@NetBSD.org
682provided some clean up for memory leaks 682provided some clean up for memory leaks
683.It 683.It
684.An Johnny Lam 684.An Johnny Lam
685.Aq Mt jlam@NetBSD.org 685.Aq Mt jlam@NetBSD.org
686provided man page fixes 686provided man page fixes
687.It 687.It
688.An Dennis Lindroos 688.An Dennis Lindroos
689.Aq Mt denafcm@gmail.com 689.Aq Mt denafcm@gmail.com
690provided a cgi-bin fix 690provided a cgi-bin fix
691.It 691.It
692.An Julio Merino 692.An Julio Merino
693.Aq Mt jmmv@NetBSD.org 693.Aq Mt jmmv@NetBSD.org
694Added the 694Added the
695.Fl P 695.Fl P
696option (pidfile support) and provided some man page fixes. 696option (pidfile support) and provided some man page fixes.
697.It 697.It
698.An Luke Mewburn 698.An Luke Mewburn
699.Aq Mt lukem@NetBSD.org 699.Aq Mt lukem@NetBSD.org
700provided many various fixes, including cgi-bin fixes and enhancements, 700provided many various fixes, including cgi-bin fixes and enhancements,
701HTTP basic authorization support and much code clean up 701HTTP basic authorization support and much code clean up
702.It 702.It
703.An Rajeev V. Pillai 703.An Rajeev V. Pillai
704.Aq Mt rajeev_v_pillai@yahoo.com 704.Aq Mt rajeev_v_pillai@yahoo.com
705provided several fixes for virtual hosting 705provided several fixes for virtual hosting
706.It 706.It
707.An Jeremy C. Reed 707.An Jeremy C. Reed
708.Aq Mt reed@NetBSD.org 708.Aq Mt reed@NetBSD.org
709provided several clean up fixes, and man page updates 709provided several clean up fixes, and man page updates
710.It 710.It
711.An Scott Reynolds 711.An Scott Reynolds
712.Aq Mt scottr@NetBSD.org 712.Aq Mt scottr@NetBSD.org
713provided various fixes 713provided various fixes
714.It 714.It
715.An Tyler Retzlaff 715.An Tyler Retzlaff
716.Aq Mt rtr@eterna.com.au 716.Aq Mt rtr@eterna.com.au
717provided SSL support, cgi-bin fixes and much other random other stuff 717provided SSL support, cgi-bin fixes and much other random other stuff
718.It 718.It
719.An rudolf 719.An rudolf
720.Aq Mt netbsd@eq.cz 720.Aq Mt netbsd@eq.cz
721provided minor compile fixes and a CGI content map fix 721provided minor compile fixes and a CGI content map fix
722.It 722.It
723.An Steve Rumble 723.An Steve Rumble
724.Aq Mt rumble@ephemeral.org 724.Aq Mt rumble@ephemeral.org
725provided the 725provided the
726.Fl V 726.Fl V
727option. 727option.
728.It 728.It
729.An Thor Lancelot Simon 729.An Thor Lancelot Simon
730.Aq Mt tls@NetBSD.org 730.Aq Mt tls@NetBSD.org
731enhanced cgi-bin support. 731enhanced cgi-bin support.
732.It 732.It
733.An Joerg Sonnenberger 733.An Joerg Sonnenberger
734.Aq Mt joerg@NetBSD.org 734.Aq Mt joerg@NetBSD.org
735implemented If-Modified-Since support 735implemented If-Modified-Since support
736.It 736.It
737.An ISIHARA Takanori 737.An ISIHARA Takanori
738.Aq Mt ishit@oak.dti.ne.jp 738.Aq Mt ishit@oak.dti.ne.jp
739provided a man page fix 739provided a man page fix
740.It 740.It
741.An Holger Weiss 741.An Holger Weiss
742.Aq Mt holger@CIS.FU-Berlin.DE 742.Aq Mt holger@CIS.FU-Berlin.DE
743provided http authorization fixes 743provided http authorization fixes
744.It 744.It
745.Aq Mt xs@kittenz.org 745.Aq Mt xs@kittenz.org
746provided chroot and change-to-user support, and other various fixes 746provided chroot and change-to-user support, and other various fixes
747.It 747.It
748Coyote Point provided various CGI fixes. 748Coyote Point provided various CGI fixes.
749.El 749.El
750.Pp 750.Pp
751There are probably others I have forgotten (let me know if you care) 751There are probably others I have forgotten (let me know if you care)
752.Pp 752.Pp
753Please send all updates to 753Please send all updates to
754.Nm 754.Nm
755to 755to
756.Aq Mt mrg@eterna.com.au 756.Aq Mt mrg@eterna.com.au
757for inclusion in future releases. 757for inclusion in future releases.
758.Sh BUGS 758.Sh BUGS
759.Nm 759.Nm
760does not handle HTTP/1.1 chunked input from the client yet. 760does not handle HTTP/1.1 chunked input from the client yet.