xref: /netbsd-src/libexec/httpd/bozohttpd.8 (revision 312631d82871c81540b81abea3baa09313478bd3)
1*312631d8Slukem.\"	$NetBSD: bozohttpd.8,v 1.99 2024/11/22 22:21:51 lukem Exp $
29240578fSmrg.\"
341f9e942Smrg.\"	$eterna: bozohttpd.8,v 1.101 2011/11/18 01:25:11 mrg Exp $
49240578fSmrg.\"
5ab3f0bd6Smrg.\" Copyright (c) 1997-2024 Matthew R. Green
69240578fSmrg.\" All rights reserved.
79240578fSmrg.\"
89240578fSmrg.\" Redistribution and use in source and binary forms, with or without
99240578fSmrg.\" modification, are permitted provided that the following conditions
109240578fSmrg.\" are met:
119240578fSmrg.\" 1. Redistributions of source code must retain the above copyright
129240578fSmrg.\"    notice, this list of conditions and the following disclaimer.
139240578fSmrg.\" 2. Redistributions in binary form must reproduce the above copyright
149240578fSmrg.\"    notice, this list of conditions and the following disclaimer in the
159240578fSmrg.\"    documentation and/or other materials provided with the distribution.
169240578fSmrg.\"
179240578fSmrg.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
189240578fSmrg.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
199240578fSmrg.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
209240578fSmrg.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
219240578fSmrg.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
229240578fSmrg.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
239240578fSmrg.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
249240578fSmrg.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
259240578fSmrg.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
269240578fSmrg.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
279240578fSmrg.\" SUCH DAMAGE.
289240578fSmrg.\"
29*312631d8Slukem.Dd November 22, 2024
301d0520b6Smrg.Dt BOZOHTTPD 8
31edbcd7c8Sjoerg.Os
329240578fSmrg.Sh NAME
331d0520b6Smrg.Nm bozohttpd
349240578fSmrg.Nd hyper text transfer protocol version 1.1 daemon
359240578fSmrg.Sh SYNOPSIS
369240578fSmrg.Nm
37c17bac1eSmartin.Op Fl EGHVXdefhnqsu
389240578fSmrg.Op Fl C Ar suffix cgihandler
3981ea280bSwiz.Op Fl I Ar port
40c9283f11Swiz.Op Fl L Ar prefix script
4181ea280bSwiz.Op Fl M Ar suffix type encoding encoding11
4219f40606Smrg.Op Fl m Ar version
4383bb4389Sjmmv.Op Fl P Ar pidfile
44026e4ac0Sjmcneill.Op Fl R Ar readme
454864410bSmrg.Op Fl S Ar version
463230a9a3Smrg.Op Fl T Ar type timeout
471e3b6bebSkamil.Op Fl U Ar username
4841f9e942Smrg.Op Fl Z Ar cert privkey
4941f9e942Smrg.Op Fl c Ar cgibin
5041f9e942Smrg.Op Fl i Ar address
5141f9e942Smrg.Op Fl p Ar pubdir
528c012591Sjnemeth.Op Fl t Ar chrootdir
539240578fSmrg.Op Fl v Ar virtualroot
549240578fSmrg.Op Fl x Ar index
5514ba2569Schristos.Op Fl z Ar ciphers
569240578fSmrg.Ar slashdir
579240578fSmrg.Op Ar myname
589240578fSmrg.Sh DESCRIPTION
599240578fSmrgThe
609240578fSmrg.Nm
619240578fSmrgprogram reads a
629240578fSmrg.Em HTTP
639240578fSmrgrequest from the standard input, and sends a reply to the standard output.
649240578fSmrgBesides ~user translation and virtual hosting support (see below), all file
659240578fSmrgrequests are from
669240578fSmrg.Ar slashdir
679240578fSmrgdirectory.
689240578fSmrgThe server uses
699240578fSmrg.Ar myname
709240578fSmrgas its name, which defaults to the local hostname, obtained from
719240578fSmrg.Xr gethostname 3
729240578fSmrg(but see the
739240578fSmrg.Fl v
749240578fSmrgoption for virtual hosting.)
759240578fSmrg.Nm
7630539536Smrgwrites logs to
7730539536Smrg.Xr syslog 3
7888b9c8a3Swizusing the ftp facility (but see the
7930539536Smrg.Fl s
80c17bac1eSmartinoption for testing and the
81c17bac1eSmartin.Fl q
8227e72db8Sandvaroption for suppressing this.)
8330539536Smrg.Nm
849240578fSmrgis designed to be small, simple and relatively featureless,
859240578fSmrghopefully increasing its security.
86b05af3b1Swiz.Ss OPTIONS
879240578fSmrgThe following options are available:
889240578fSmrg.Bl -tag -width xxxcgibin
899240578fSmrg.It Fl b
90*312631d8SlukemEnables stand-alone daemon mode, where
919240578fSmrg.Nm
92*312631d8Slukemdetaches from the current terminal and runs in the background
93*312631d8Slukem(unless invoked with
94*312631d8Slukem.Fl f ) ,
95*312631d8Slukemlistens on the appropriate IP address
96*312631d8Slukem(see
97*312631d8Slukem.Fl i Ar address )
98*312631d8Slukemand TCP port
99*312631d8Slukem(see
100*312631d8Slukem.Fl I Ar port ) ,
101*312631d8Slukemand services HTTP requests.
102*312631d8Slukem.Nm
103*312631d8Slukemdoes not use
104*312631d8Slukem.Xr inetd 8
105*312631d8Slukemin stand-alone daemon mode.
1069240578fSmrg.It Fl C Ar suffix cgihandler
10794a4f45fSjmmvAdds a new CGI handler program for a particular file type.
1089240578fSmrgThe
1099240578fSmrg.Ar suffix
1109240578fSmrgshould be any normal file suffix, and the
1119240578fSmrg.Ar cgihandler
1129240578fSmrgshould be a full path to an interpreter.
1139240578fSmrgThis option is the only way to enable CGI programs that exist
1149240578fSmrgoutside of the cgibin directory to be executed.
1159240578fSmrgMultiple
1169240578fSmrg.Fl C
1179240578fSmrgoptions may be passed.
1189240578fSmrg.It Fl c Ar cgibin
11994a4f45fSjmmvEnables the CGI/1.1 interface.
1209240578fSmrgThe
1219240578fSmrg.Ar cgibin
1229240578fSmrgdirectory is expected to contain the CGI programs to be used.
1239240578fSmrg.Nm
124*312631d8Slukemlooks for URLs in the form of
125*312631d8Slukem.Ql /cgi-bin/ Ns Ar scriptname
1269240578fSmrgwhere
127*312631d8Slukem.Ar scriptname
1289240578fSmrgis a valid CGI program in the
1299240578fSmrg.Ar cgibin
1309240578fSmrgdirectory.
131*312631d8SlukemIn other words, all CGI URLs must begin with
132*312631d8Slukem.Ql \%/cgi-bin/ .
133c4fe1facSshmNote that the CGI/1.1 interface is available with
134*312631d8Slukem.Ql ~user
135c4fe1facSshmtranslation using
136c4fe1facSshm.Fl E
137c4fe1facSshmswitch.
1384864410bSmrg.It Fl d
1394864410bSmrgEnables debug support.
1404864410bSmrg.It Fl E
1414864410bSmrgEnables CGI/1.1 interface for
142*312631d8Slukem.Ql ~user
1434864410bSmrgtranslation.
1444864410bSmrgNote that enabling this support implies that users can run commands
1458f3596c5Swizas the web server user.
1468f3596c5SwizThis may have security implications.
1479240578fSmrg.It Fl e
148*312631d8SlukemDo not clear the environment when used with either the
1499240578fSmrg.Fl t
1509240578fSmrgor
1519240578fSmrg.Fl U
1529240578fSmrgoptions.
153c6e75af2Smrg.It Fl f
15494a4f45fSjmmvStops the
155c6e75af2Smrg.Fl b
156*312631d8Slukemoption from detaching
157c6e75af2Smrg.Nm
158*312631d8Slukemfrom the tty and going into the background as part of stand-alone daemon mode.
1598f3596c5SwizThis implies the
1604864410bSmrg.Fl b
161*312631d8Slukemoption.
16220563328Sagc.It Fl G
16320563328SagcGet the
16420563328Sagc.Nm
16520563328Sagcversion string, print it on standard output, and exit.
1669240578fSmrg.It Fl H
167*312631d8SlukemChanges directory index mode
168*312631d8Slukem(see
169*312631d8Slukem.Fl X
170*312631d8Slukemoption)
171*312631d8Slukemto hide files and directories that start with a period
172*312631d8Slukem.Pq Ql \&. ,
173*312631d8Slukemexcept for
1749240578fSmrg.Pa .. .
1759240578fSmrg.It Fl I Ar port
176*312631d8SlukemUse
1779240578fSmrg.Ar port
178d0ddf3e7Smrginstead of the default
1799240578fSmrg.Dq http
180*312631d8Slukemport
181*312631d8Slukem(usually 80, see
182*312631d8Slukem.Xr services 5 ) .
183d0ddf3e7SmrgWhen used with the
1849240578fSmrg.Fl b
185*312631d8Slukemor
186*312631d8Slukem.Fl f
187*312631d8Slukemoptions, this option changes the bound port.
188*312631d8SlukemOtherwise this option forces redirections to use this port
189*312631d8Slukeminstead of the value obtained via
190d0ddf3e7Smrg.Xr getsockname 2 .
19194a4f45fSjmmv.It Fl i Ar address
192*312631d8SlukemUse
1939240578fSmrg.Ar address
194*312631d8Slukemas the address to bind to in stand-alone daemon mode.
195*312631d8SlukemIf this option is not provided, all available IP addresses
196*312631d8Slukemwill be listened to.
197bbbdac0aSmrgOnly the last
198bbbdac0aSmrg.Fl i
199bbbdac0aSmrgoption is used.
20094a4f45fSjmmvThis option is only valid with the
20194a4f45fSjmmv.Fl b
202*312631d8Slukemor
203*312631d8Slukem.Fl f
204*312631d8Slukemoptions.
205c9283f11Swiz.It Fl L Ar prefix script
206c9283f11SwizAdds a new Lua script for a particular prefix.
207c9283f11SwizThe
208c9283f11Swiz.Ar prefix
209c9283f11Swizshould be an arbitrary text, and the
210c9283f11Swiz.Ar script
211c9283f11Swizshould be a full path to a Lua script.
212c9283f11SwizMultiple
213c9283f11Swiz.Fl L
214c9283f11Swizoptions may be passed.
215c9283f11SwizA separate Lua state is created for each prefix.
216c9283f11SwizThe Lua script can register callbacks using the
217*312631d8Slukem.Dl httpd.register_handler('suffixpath', luafunc)
218*312631d8SlukemLua function,
219c9283f11Swizwhich will trigger the execution of the Lua function
220*312631d8Slukem.Fn luafunc
221c9283f11Swizwhen a URL in the form
222*312631d8Slukem.Sm off
223*312631d8Slukem.Li http:// Ar hostname Li / Ar prefix Li / Ar suffixpath
224*312631d8Slukem.Sm on
225c9283f11Swizis being accessed.
226c9283f11SwizThe function is passed three tables as arguments, the server
227c9283f11Swizenvironment, the request headers, and the decoded query string
228cad7fa13Sabhinavplus any data that was sent as application/x-www-form-urlencoded.
2299240578fSmrg.It Fl M Ar suffix type encoding encoding11
23094a4f45fSjmmvAdds a new entry to the table that converts file suffixes to
2319240578fSmrgcontent type and encoding.
2329240578fSmrgThis option takes four additional arguments containing
2339240578fSmrgthe file prefix, its
2349240578fSmrg.Dq Content-Type ,
235b05af3b1Swiz.Dq Content-Encoding ,
2369240578fSmrgand
2379240578fSmrg.Dq Content-Encoding
2389240578fSmrgfor HTTP/1.1 connections, respectively.
239b05af3b1SwizIf any of these are a single dash
240b05af3b1Swiz.Pq Dq - ,
241b05af3b1Swizthe empty string is used instead.
2429240578fSmrgMultiple
2439240578fSmrg.Fl M
2449240578fSmrgoptions may be passed.
24519f40606Smrg.It Fl m Ar version
24619f40606SmrgSet the minimum supported SSL protocol
24719f40606Smrg.Ar version .
24819f40606SmrgThe valid values of
24919f40606Smrg.Ar version
25019f40606Smrgare
25119f40606Smrg.Dq TLSv1.1 ,
25219f40606Smrg.Dq TLSv1.2 ,
25319f40606Smrgand
25419f40606Smrg.Dq TLSv1.3 .
25519f40606SmrgThe default version is
25619f40606Smrg.Dq TLSv1.1 .
2579240578fSmrg.It Fl n
25894a4f45fSjmmvStops
2599240578fSmrg.Nm
2604864410bSmrgfrom doing IP address to name resolution of remote hosts.
2614864410bSmrgThis affects the
2629240578fSmrg.Ev REMOTE_HOST
2634864410bSmrgenvironment variable for CGI programs and Lua scripts.
26483bb4389Sjmmv.It Fl P Ar pidfile
265*312631d8SlukemCreate a PID file in
26683bb4389Sjmmv.Ar pidfile
26783bb4389Sjmmvwhen run in daemon mode with the
26883bb4389Sjmmv.Fl b
269*312631d8Slukemor
270*312631d8Slukem.Fl f
271*312631d8Slukemoptions.
2729240578fSmrg.It Fl p Ar pubdir
27394a4f45fSjmmvChanges the default user directory for
274*312631d8Slukem.Ql /~user/
2759240578fSmrgtranslations from
276*312631d8Slukem.Pa public_html
2779240578fSmrgto
2789240578fSmrg.Ar pubdir .
279c17bac1eSmartin.It Fl q
280c17bac1eSmartinQuiet mode - no log entries generated.
281026e4ac0Sjmcneill.It Fl R Ar readme
282*312631d8SlukemWhen directory indexing is enabled
283*312631d8Slukem(see
284*312631d8Slukem.Fl X
285*312631d8Slukemoption),
286*312631d8Slukeminclude the contents of the file
287026e4ac0Sjmcneill.Ar readme
288026e4ac0Sjmcneillin the footer of the directory index.
2894864410bSmrg.It Fl S Ar version
29094a4f45fSjmmvSets the internal server version to
2914864410bSmrg.Ar version .
2929240578fSmrg.It Fl s
29394a4f45fSjmmvForces logging to be set to stderr always.
2943230a9a3Smrg.It Fl T Ar type timeout
2953230a9a3SmrgSet the timeout for
2963230a9a3Smrg.Ar type
2973230a9a3Smrgto
2983230a9a3Smrg.Ar timeout .
2993230a9a3SmrgThe valid values of
3003230a9a3Smrg.Ar type
3013230a9a3Smrgare
30208dbfa23Smrg.Dq ssl timeout ,
3033230a9a3Smrg.Dq initial timeout ,
3043230a9a3Smrg.Dq header timeout ,
3053230a9a3Smrgand
3063230a9a3Smrg.Dq request timeout .
30708dbfa23SmrgThe default values are 30 seconds, 30 seconds, 10 seconds and 600 seconds,
30808dbfa23Smrgrespectively.
3099240578fSmrg.It Fl t Ar chrootdir
31094a4f45fSjmmvMakes
3119240578fSmrg.Nm
31294a4f45fSjmmvchroot to the specified directory
3139240578fSmrgbefore answering requests.
3149240578fSmrgEvery other path should be specified relative
3159240578fSmrgto the new root, if this option is used.
3169240578fSmrgNote that the current environment
3179240578fSmrgis normally replaced with an empty environment with this option, unless the
3189240578fSmrg.Fl e
3199240578fSmrgoption is also used.
3209240578fSmrg.It Fl U Ar username
321*312631d8SlukemSwitch to the user and the groups of
3229240578fSmrg.Ar username
3239240578fSmrgafter initialization.
3249240578fSmrgThis option, like
3259240578fSmrg.Fl t
3269240578fSmrgabove, causes
3279240578fSmrg.Nm
3289240578fSmrgto clear the environment unless the
3299240578fSmrg.Fl e
3309240578fSmrgoption is given.
3319240578fSmrg.It Fl u
33294a4f45fSjmmvEnables the transformation of Uniform Resource Locators of
3339240578fSmrgthe form
334*312631d8Slukem.Ql /~user/
33512496162Smbalmerinto the directory
3369240578fSmrg.Pa ~user/public_html
3379240578fSmrg(but see the
3389240578fSmrg.Fl p
3399240578fSmrgoption above).
3409240578fSmrg.It Fl V
341da548da1SmrgSets the backup virtual host directory to the
342da548da1Smrg.Ar slashdir
343da548da1Smrgargument.
3449240578fSmrgIf no directory exists in
3459240578fSmrg.Ar virtualroot
3469240578fSmrgfor the request, then
3479240578fSmrg.Ar slashdir
3489240578fSmrgwill be used.
349ffa84063SwizThe default behavior is to return 404 (Not Found.)
3509240578fSmrg.It Fl v Ar virtualroot
35194a4f45fSjmmvEnables virtual hosting support.
3529240578fSmrgDirectories in
3539240578fSmrg.Ar virtualroot
3549240578fSmrgwill be searched for a matching virtual host name, when parsing
3559240578fSmrgthe HTML request.
3569240578fSmrgIf a matching name is found, it will be used
3579240578fSmrgas both the server's real name,
3589240578fSmrg.Op Ar myname ,
3599240578fSmrgand as the
3609240578fSmrg.Ar slashdir .
3619240578fSmrgSee the
3629240578fSmrg.Sx EXAMPLES
3639240578fSmrgsection for an example of using this option.
3649240578fSmrg.It Fl X
36594a4f45fSjmmvEnables directory indexing.
366*312631d8SlukemA directory index will be generated only when the default
367*312631d8Slukemindex file is not present
368*312631d8Slukem(i.e.,
3699240578fSmrg.Pa index.html
370*312631d8Slukemunless changed with
371*312631d8Slukem.Fl x Ar index ) .
3729240578fSmrg.It Fl x Ar index
37394a4f45fSjmmvChanges the default file read for directories from
374*312631d8Slukem.Pa index.html
3759240578fSmrgto
3769240578fSmrg.Ar index .
3779240578fSmrg.It Fl Z Ar certificate_path privatekey_path
37894a4f45fSjmmvSets the path to the server certificate file and the private key file
379ffa84063Swizin PEM format.
380*312631d8SlukemThis option also causes
381707281a2Smrg.Nm
382707281a2Smrgto start SSL mode.
3834864410bSmrg.It Fl z Ar ciphers
3844864410bSmrgSets the list of SSL ciphers (see
3854864410bSmrg.Xr SSL_CTX_set_cipher_list 3 ) .
3869240578fSmrg.El
3879240578fSmrg.Pp
3889240578fSmrgNote that in
3899240578fSmrg.Nm
3909240578fSmrgversions 20031005 and prior that supported the
3919240578fSmrg.Fl C
3929240578fSmrgand
3939240578fSmrg.Fl M
3949240578fSmrgoptions, they took a single space-separated argument that was parsed.
3959240578fSmrgsince version 20040828, they take multiple options (2 in the case of
3969240578fSmrg.Fl C
3979240578fSmrgand 4 in the case of
3989240578fSmrg.Fl M . )
399b05af3b1Swiz.Ss INETD CONFIGURATION
400*312631d8SlukemBy default
4019240578fSmrg.Nm
4029240578fSmrguses
4039240578fSmrg.Xr inetd 8
4049240578fSmrgby default to process incoming TCP connections for HTTP requests
405*312631d8Slukem(unless stand-alone daemon mode is enabled with the
4069240578fSmrg.Fl b
407*312631d8Slukemor
408*312631d8Slukem.Fl f
409*312631d8Slukemoptions),
4109240578fSmrg.Nm
4119240578fSmrghas little internal networking knowledge.
412*312631d8Slukem(Indeed, you can run
413*312631d8Slukem.Nm
414*312631d8Slukemon the command line with little change of functionality.)
4159240578fSmrgA typical
4169240578fSmrg.Xr inetd.conf 5
4179240578fSmrgentry would be:
4189240578fSmrg.Bd -literal
4199240578fSmrghttp stream tcp  nowait:600 _httpd /usr/libexec/httpd httpd /var/www
4209240578fSmrghttp stream tcp6 nowait:600 _httpd /usr/libexec/httpd httpd /var/www
4219240578fSmrg.Ed
4229240578fSmrg.Pp
4239240578fSmrgThis would serve web pages from
4249240578fSmrg.Pa /var/www
4259240578fSmrgon both IPv4 and IPv6 ports.
4269240578fSmrgThe
427*312631d8Slukem.Ql :600
4289240578fSmrgchanges the
4299240578fSmrgrequests per minute to 600, up from the
4309240578fSmrg.Xr inetd 8
4319240578fSmrgdefault of 40.
4329240578fSmrg.Pp
4339240578fSmrgUsing the
4349240578fSmrg.Nx
4359240578fSmrg.Xr inetd 8 ,
4369240578fSmrgyou can provide multiple IP-address based HTTP servers by having multiple
4379240578fSmrglistening ports with different configurations.
438b05af3b1Swiz.Ss NOTES
4399240578fSmrgThis server supports the
4409240578fSmrg.Em HTTP/0.9 ,
441b05af3b1Swiz.Em HTTP/1.0 ,
4429240578fSmrgand
4439240578fSmrg.Em HTTP/1.1
444707281a2Smrgstandards.
445707281a2SmrgSupport for these protocols is very minimal and many optional features are
446707281a2Smrgnot supported.
4479240578fSmrg.Pp
4489240578fSmrg.Nm
4498af74a22Smrgcan be compiled without
4508af74a22SmrgCGI support (NO_CGIBIN_SUPPORT),
4518af74a22Smrguser transformations (NO_USER_SUPPORT),
4528af74a22Smrgdirectory index support (NO_DIRINDEX_SUPPORT),
4538af74a22Smrgdaemon mode support (NO_DAEMON_MODE),
4548af74a22Smrgdynamic MIME content (NO_DYNAMIC_CONTENT),
455b4615208SabhinavLua support (NO_LUA_SUPPORT),
4568af74a22Smrgand SSL support (NO_SSL_SUPPORT)
4578af74a22Smrgby defining the listed macros when building
4589240578fSmrg.Nm .
459ffa84063Swiz.Ss HTTP BASIC AUTHORIZATION
4609240578fSmrg.Nm
461ffa84063Swizhas support for HTTP Basic Authorization.
4629240578fSmrgIf a file named
4639240578fSmrg.Pa .htpasswd
4649240578fSmrgexists in the directory of the current request,
4659240578fSmrg.Nm
4669240578fSmrgwill restrict access to documents in that directory
4679240578fSmrgusing the RFC 2617 HTTP
4689240578fSmrg.Dq Basic
4699240578fSmrgauthentication scheme.
4709240578fSmrg.Pp
4719240578fSmrgNote:
4729240578fSmrgThis does not recursively protect any sub-directories.
4739240578fSmrg.Pp
4749240578fSmrgThe
4759240578fSmrg.Pa .htpasswd
4769240578fSmrgfile contains lines delimited with a colon containing
4779240578fSmrguser names and passwords hashed with
4789240578fSmrg.Xr crypt 3 ,
4799240578fSmrgfor example:
4809240578fSmrg.Bd -literal
4819240578fSmrgheather:$1$pZWI4tH/$DzDPl63i6VvVRv2lJNV7k1
4829240578fSmrgjeremy:A.xewbx2DpQ8I
4839240578fSmrg.Ed
4849240578fSmrg.Pp
4859240578fSmrgOn
4869240578fSmrg.Nx ,
4879240578fSmrgthe
4889240578fSmrg.Xr pwhash 1
4899240578fSmrgutility may be used to generate hashed passwords.
490707281a2Smrg.Pp
491707281a2SmrgWhile
492707281a2Smrg.Nm
493707281a2Smrgdistributed with
494707281a2Smrg.Nx
495ffa84063Swizhas support for HTTP Basic Authorization enabled by default,
496*312631d8Slukemin the portable distribution this feature is disabled.
497707281a2SmrgCompile
498707281a2Smrg.Nm
499707281a2Smrgwith
500707281a2Smrg.Dq -DDO_HTPASSWD
5018c012591Sjnemethon the compiler command line to enable this support.
502*312631d8SlukemThis may require linking with the crypt library, using
503707281a2Smrg.Dq -lcrypt .
504c0b4b2d2Sjruoho.Ss BLOCKLIST SUPPORT
5058062a675SwizOn
5068062a675Swiz.Nx ,
507c0b4b2d2Sjruoho.Nm
508c0b4b2d2Sjruohosupports
509c0b4b2d2Sjruoho.Xr blocklistd 8
510c0b4b2d2Sjruohoby default.
511c0b4b2d2SjruohoThe support can be disabled with the
512c0b4b2d2Sjruoho.Dq -DNO_BLOCKLIST_SUPPORT
513c0b4b2d2Sjruohocompilation option.
514c0b4b2d2Sjruoho.Pp
515c0b4b2d2SjruohoUpon occurrence,
516c0b4b2d2Sjruoho.Nm
517830b8c52Sjruohoreports two HTTP status codes to
518c0b4b2d2Sjruoho.Xr blocklistd 8
519c0b4b2d2Sjruohoas failures:
520*312631d8Slukem.Er 401
521830b8c52Sjruoho(``Unauthorized'')
522c0b4b2d2Sjruohoand
523*312631d8Slukem.Er 403
524830b8c52Sjruoho(``Forbidden'') .
525c0b4b2d2SjruohoOf these,
526*312631d8Slukem.Er 401
527c0b4b2d2Sjruohois the one received upon authorization failure with the
528c0b4b2d2SjruohoHTTP Basic Authorization mechanism.
529c0b4b2d2SjruohoA successful authorization decreases the counter kept by
530c0b4b2d2Sjruoho.Xr blocklistd 8 .
531c0b4b2d2Sjruoho.Pp
532c0b4b2d2SjruohoNote that the implementation of the HTTP Basic Authorization mechanism
533c0b4b2d2Sjruohouses a redirection; a status code
534*312631d8Slukem.Er 401
535c0b4b2d2Sjruohois always initially received.
536c0b4b2d2SjruohoTherefore, a single authorization failure of
537c0b4b2d2Sjruoho.Pa .htpasswd
538c0b4b2d2Sjruohois reported as two failures to
539c0b4b2d2Sjruoho.Xr blocklistd 8 ,
540c0b4b2d2Sjruohobut no failures are recorded upon successful authorization
541c0b4b2d2Sjruohodue to the decrease of the failure counter.
542b05af3b1Swiz.Ss SSL SUPPORT
5439240578fSmrg.Nm
54414ba2569Schristoshas support for TLSv1.1 and TLSv1.2 protocols that are included by
5458c012591Sjnemethdefault.
546*312631d8SlukemThis requires linking with the crypto and ssl library, using
5479240578fSmrg.Dq -lcrypto -lssl .
5489240578fSmrgTo disable SSL SUPPORT compile
5499240578fSmrg.Nm
5509240578fSmrgwith
5519240578fSmrg.Dq -DNO_SSL_SUPPORT
5529240578fSmrgon the compiler command line.
55311179568Smrg.Pp
55411179568SmrgTo have an enforced redirect, such as http to https, create a shadow
55511179568Smrgdirectory root that contains a
55611179568Smrg.Pa .bzabsredirect
55711179568Smrgfile that points to the real target.
558f082d14aSelric.Ss COMPRESSION
559f082d14aSelric.Nm
560cad7fa13Sabhinavsupports a very basic form of compression.
561f082d14aSelric.Nm
56200872173Swizwill serve the requested file postpended with
56300872173Swiz.Dq Pa .gz
56400872173Swizif it exists, it is readable, the client requested gzip compression, and
565f082d14aSelricthe client did not make a ranged request.
566859dc97dSwiz.Sh FILES
567859dc97dSwiz.Nm
568*312631d8Slukemprocesses specific files in each directory that
569*312631d8Slukemenables certain features on a per-directory basis.
570*312631d8SlukemThese per-directory files are:
571*312631d8Slukem.Bl -tag -width .htpasswd
572*312631d8Slukem.It Pa .bzabsredirect
573*312631d8SlukemSymbolic link to the absolute URL pointed to by this symlink.
574*312631d8SlukemThis is useful to redirect to different servers.
575*312631d8SlukemSee
576*312631d8Slukem.Sx SYMBOLIC LINK REDIRECTION .
577*312631d8Slukem.It Pa .bzredirect
578*312631d8SlukemSymbolic link to URL for
579859dc97dSwiz.Nm
580*312631d8Slukemto perform a smart redirect to the target of this symlink.
581859dc97dSwizThe target is assumed to live on the same server.
582c4fe1facSshmIf target starts with slash then absolute redirection is performed,
583*312631d8Slukemotherwise it is handled as relative.
584*312631d8SlukemSee
585*312631d8Slukem.Sx SYMBOLIC LINK REDIRECTION .
586*312631d8Slukem.It Pa .bzremap
587*312631d8SlukemUsed by rewrite mappings; see
588*312631d8Slukem.Sx REWRITE MAPPINGS .
589*312631d8Slukem.It Pa .htpasswd
590*312631d8SlukemUsed by HTTP basic authorization; see
591*312631d8Slukem.Sx HTTP BASIC AUTHORIZATION .
592*312631d8Slukem.El
593*312631d8Slukem.Ss SYMBOLIC LINK REDIRECTION
594*312631d8SlukemTwo forms of redirection are supported:
595*312631d8Slukem.Bl -enum
596*312631d8Slukem.It
597*312631d8SlukemA symbolic link without schema will use
598*312631d8Slukem.Li http://
599*312631d8Slukemas default.
600*312631d8SlukemE.g., a symbolic link to
601*312631d8Slukem.Pa NetBSD.org
602c4fe1facSshmwill redirect to
603*312631d8Slukem.Lk http://NetBSD.org/ .
604*312631d8Slukem.It
605*312631d8SlukemA symbolic link with a schema uses the provided schema.
606*312631d8SlukemE.g., a symbolic link to
607*312631d8Slukem.Pa ftp://NetBSD.org/
608*312631d8Slukemwill redirect to
609*312631d8Slukem.Lk ftp://NetBSD.org/ .
610*312631d8Slukem.El
611*312631d8Slukem.Ss REWRITE MAPPINGS
612bf2f242dSmartinIf a
613bf2f242dSmartin.Pa .bzremap
614bf2f242dSmartinfile is found at the root of a (virtual) server, it is expected to contain
615bf2f242dSmartinrewrite mappings for URLs.
616bf2f242dSmartin.Pp
617bf2f242dSmartinThese remappings are performed internally in the server before authentication
618bf2f242dSmartinhappens and can be used to hide implementation details, like the CGI handler
619bf2f242dSmartinspecific suffix for non cgi scripts in authorized directories.
620bf2f242dSmartin.Pp
621bf2f242dSmartinThe map file consists of lines two paths separated by a colon, where the left
622bf2f242dSmartinside needs to exactly match a (sub) path of the request and will be replaced
623bf2f242dSmartinby the right side.
624bf2f242dSmartin.Pp
625bf2f242dSmartinThe first match always wins.
626bf2f242dSmartin.Pp
627bf2f242dSmartinA
628bf2f242dSmartin.Pa .bzremap
629bf2f242dSmartinfile could look like this:
630bf2f242dSmartin.Bd -literal
631bf2f242dSmartin/nic/update:/auth-dir/updipv4.pl
632bf2f242dSmartin.Ed
633bf2f242dSmartin.Pp
634bf2f242dSmartinThe remap file should be short, access to it is slow and needs to happen
635bf2f242dSmartinon each request.
636bf2f242dSmartinIf a request path needs to include a colon
637*312631d8Slukem.Pq Ql \&:
638bf2f242dSmartincharacter, it can be escaped
639bf2f242dSmartinwith a backslash
640*312631d8Slukem.Pq Ql \e
641bf2f242dSmartinThe right hand side of the colon is always used verbatim, no escape sequences
642bf2f242dSmartinare interpreted.
643859dc97dSwiz.Sh EXAMPLES
644859dc97dSwizTo configure set of virtual hosts, one would use an
645859dc97dSwiz.Xr inetd.conf 5
646859dc97dSwizentry like:
647859dc97dSwiz.Bd -literal
648859dc97dSwizhttp stream tcp  nowait:600 _httpd /usr/libexec/httpd httpd -v /var/vroot /var/www
649859dc97dSwiz.Ed
650859dc97dSwiz.Pp
651859dc97dSwizand inside
652859dc97dSwiz.Pa /var/vroot
653859dc97dSwizcreate a directory (or a symlink to a directory) with the same name as
654859dc97dSwizthe virtual host, for each virtual host.
655ca768e99SmrgLookups for these names are done in a case-insensitive manner, and may
656ca768e99Smrginclude the port number part of the request, allowing for distinct
657ca768e99Smrgvirtual hosts on the same name.
658859dc97dSwiz.Pp
659859dc97dSwizTo use
660859dc97dSwiz.Nm
661859dc97dSwizwith PHP, one must use the
662859dc97dSwiz.Fl C
663859dc97dSwizoption to specify a CGI handler for a particular file type.
66492d8a7baSreedTypically this will be like:
665859dc97dSwiz.Bd -literal
66627da98ffSmrghttpd -C .php /usr/pkg/bin/php-cgi /var/www
667859dc97dSwiz.Ed
668ffa84063Swiz.Pp
669ffa84063SwizNote that a plain script interpreter can not be used directly as a cgihandler,
670ffa84063Swizas there are no command line options passed from
671ffa84063Swiz.Nm
672ffa84063Swizto avoid security issues.
673ffa84063Swiz.Pp
674ffa84063SwizIf no CGI-aware wrapper exists, a simple shell script like the following
675ffa84063Swizmight do.
676ffa84063Swiz.Pp
677ffa84063SwizIt would be invoked like:
678ffa84063Swiz.Bd -literal
679ffa84063Swizhttpd -C .pl /www-scripts/bin/run.perl /var/www
680ffa84063Swiz.Ed
681ffa84063Swizand the script could look like:
682ffa84063Swiz.Bd -literal
683ffa84063Swiz#! /bin/sh
684ffa84063Swiz
685ffa84063Swizif [ -r "$SCRIPT_FILENAME" -a -x "$SCRIPT_FILENAME" ]; then
686ffa84063Swiz	exec /usr/pkg/bin/perl "$SCRIPT_FILENAME"
687ffa84063Swizfi
688ffa84063Swiz
689ffa84063Swizexit 1
690ffa84063Swiz.Ed
6919240578fSmrg.Sh SEE ALSO
6929240578fSmrg.Xr inetd.conf 5 ,
693*312631d8Slukem.Xr services 5 ,
6949240578fSmrg.Xr inetd 8
6959240578fSmrg.Sh HISTORY
6969240578fSmrg.Nm
6971d0520b6Smrgwas first written in perl, based on another perl http server
6989240578fSmrgcalled
6999240578fSmrg.Dq tinyhttpd .
7009240578fSmrgIt was then rewritten from scratch in perl, and then once again in C.
70103387632SmrgFrom
7029240578fSmrg.Dq bozohttpd
70303387632Smrgversion 20060517, it has been integrated into
70403387632Smrg.Nx .
7059240578fSmrgThe focus has always been simplicity and security, with minimal features
7069240578fSmrgand regular code audits.
707707281a2SmrgThis manual documents
708707281a2Smrg.Nm
7093d0aa1daSmayaversion 20240428.
7109240578fSmrg.Sh AUTHORS
711c9283f11Swiz.An -nosplit
7129240578fSmrg.Nm
713c9283f11Swizwas written by
714c9283f11Swiz.An Matthew R. Green
715ab3f0bd6Smrg.Aq Mt mrg@eterna23.net .
7169240578fSmrg.Pp
7179240578fSmrgThe large list of contributors includes:
7189240578fSmrg.Bl -dash
7199240578fSmrg.It
720c9283f11Swiz.An Christoph Badura
721c9283f11Swiz.Aq Mt bad@bsd.de
722707281a2Smrgprovided Range: header support
723707281a2Smrg.It
72448003606Smrg.An Marc Balmer
72548003606Smrg.Aq Mt mbalmer@NetBSD.org
72648003606Smrgadded Lua support for dynamic content creation
72748003606Smrg.It
728c9283f11Swiz.An Sean Boudreau
729c9283f11Swiz.Aq Mt seanb@NetBSD.org
7308d65c98fSwizprovided a security fix for virtual hosting
731df5be573Smrg.It
732c9283f11Swiz.An Julian Coleman
733c9283f11Swiz.Aq Mt jdc@coris.org.uk
7349240578fSmrgprovided an IPv6 bugfix
7359240578fSmrg.It
736c9283f11Swiz.An Chuck Cranor
737c9283f11Swiz.Aq Mt chuck@research.att.com
7389240578fSmrgprovided cgi-bin support fixes, and more
7399240578fSmrg.It
7408af74a22Smrg.An Alistair G. Crooks
7418af74a22Smrg.Aq Mt agc@NetBSD.org
7421d0520b6Smrgcleaned up many internal interfaces, made
7431d0520b6Smrg.Nm
7449b91523eSmrglinkable as a library and provided the Lua binding
7458af74a22Smrg.It
746c9283f11Swiz.An DEGROOTE Arnaud
747c9283f11Swiz.Aq Mt degroote@NetBSD.org
74803387632Smrgprovided a fix for daemon mode
74903387632Smrg.It
750c9283f11Swiz.An Andrew Doran
751c9283f11Swiz.Aq Mt ad@NetBSD.org
7529240578fSmrgprovided directory indexing support
7539240578fSmrg.It
754c9283f11Swiz.An Roland Dowdeswell
755c9283f11Swiz.Aq Mt elric@NetBSD.org
756a4b84ca0Smrgadded support for serving gzipped files and better SSL handling
757a4b84ca0Smrg.It
75848003606Smrg.An Per Ekman
75948003606Smrg.Aq Mt pek@pdc.kth.se
76048003606Smrgprovided a fix for a minor (non-security) buffer overflow condition
76148003606Smrg.It
7621bf054d1Smrg.Aq Mt emily@ingalls.rocks
7631bf054d1Smrgprovided fixes for some bad request parsing
7641bf054d1Smrg.It
765c9283f11Swiz.An Jun-ichiro itojun Hagino, KAME
766c9283f11Swiz.Aq Mt itojun@iijlab.net
7679240578fSmrgprovided initial IPv6 support
7689240578fSmrg.It
769c9283f11Swiz.An Martin Husemann
770c9283f11Swiz.Aq Mt martin@NetBSD.org
771560f0b4fSmrgprovided .bzabsredirect and .bzredir support, fixed various
772560f0b4fSmrgredirection issues and more
7739240578fSmrg.It
774c9283f11Swiz.An Arto Huusko
775c9283f11Swiz.Aq Mt arto.huusko@pp2.inet.fi
77603387632Smrgprovided fixes cgi-bin
77703387632Smrg.It
778c9283f11Swiz.An Roland Illig
779c9283f11Swiz.Aq Mt roland.illig@gmx.de
7809240578fSmrgprovided some off-by-one fixes
7819240578fSmrg.It
782c9283f11Swiz.An Zak Johnson
783c9283f11Swiz.Aq Mt zakj@nox.cx
78403387632Smrgprovided cgi-bin enhancements
78503387632Smrg.It
786c9283f11Swiz.An Nicolas Jombart
787c9283f11Swiz.Aq Mt ecu@ipv42.net
788ffa84063Swizprovided fixes for HTTP basic authorization support
7899240578fSmrg.It
790c9283f11Swiz.An Antti Kantee
791c9283f11Swiz.Aq Mt pooka@NetBSD.org
792ffa84063Swizprovided fixes for HTTP basic authorization support
793a4b84ca0Smrg.It
794c9283f11Swiz.An Thomas Klausner
795c9283f11Swiz.Aq Mt wiz@NetBSD.org
7969240578fSmrgprovided many fixes and enhancements for the man page
7979240578fSmrg.It
7984135f5d4Smrg.An Mateusz Kocielski
7994135f5d4Smrg.Aq Mt shm@NetBSD.org
8007d14271cSshmfixed memory leaks, various issues with userdir support,
8017d14271cSshminformation disclosure issues, added support for using CGI handlers
80227da98ffSmrgwith directory indexing, found several security issues and provided
8039b91523eSmrgvarious other fixes
8044135f5d4Smrg.It
8058af74a22Smrg.An Arnaud Lacombe
8068af74a22Smrg.Aq Mt alc@NetBSD.org
8078af74a22Smrgprovided some clean up for memory leaks
8088af74a22Smrg.It
809c9283f11Swiz.An Johnny Lam
810c9283f11Swiz.Aq Mt jlam@NetBSD.org
8119240578fSmrgprovided man page fixes
8129240578fSmrg.It
813630f2c0bSmrg.An Dennis Lindroos
814630f2c0bSmrg.Aq Mt denafcm@gmail.com
815630f2c0bSmrgprovided a cgi-bin fix
816630f2c0bSmrg.It
8171bf054d1Smrg.An Jared McNeill
8181bf054d1Smrg.Aq Mt jmcneill@NetBSD.org
8191bf054d1Smrgadded support for readme in directory indexing
8201bf054d1Smrg.It
821c9283f11Swiz.An Julio Merino
822c9283f11Swiz.Aq Mt jmmv@NetBSD.org
823a4b84ca0SmrgAdded the
824a4b84ca0Smrg.Fl P
8259b91523eSmrgoption (pidfile support) and provided some man page fixes
826a4b84ca0Smrg.It
827c9283f11Swiz.An Luke Mewburn
828c9283f11Swiz.Aq Mt lukem@NetBSD.org
829b05af3b1Swizprovided many various fixes, including cgi-bin fixes and enhancements,
830ffa84063SwizHTTP basic authorization support and much code clean up
8319240578fSmrg.It
83219f40606Smrg.An Sunil Nimmagadda
83319f40606Smrg.Aq Mt sunil@nimmagadda.net
83419f40606Smrgprovided runtime TLS version control
83519f40606Smrg.It
836ca768e99Smrg.An Rajeev V. Pillai
837ca768e99Smrg.Aq Mt rajeev_v_pillai@yahoo.com
8389b91523eSmrgprovided several fixes for virtual hosting and directory indexing and
8399b91523eSmrgfixes for CGI
840ca768e99Smrg.It
841c9283f11Swiz.An Jeremy C. Reed
842c9283f11Swiz.Aq Mt reed@NetBSD.org
843707281a2Smrgprovided several clean up fixes, and man page updates
844707281a2Smrg.It
845c9283f11Swiz.An Scott Reynolds
846c9283f11Swiz.Aq Mt scottr@NetBSD.org
8479240578fSmrgprovided various fixes
8489240578fSmrg.It
849c9283f11Swiz.An Tyler Retzlaff
850ab3f0bd6Smrg.Aq Mt rtr@eterna23.net
851707281a2Smrgprovided SSL support, cgi-bin fixes and much other random other stuff
8529240578fSmrg.It
853c9283f11Swiz.An rudolf
854c9283f11Swiz.Aq Mt netbsd@eq.cz
855df5be573Smrgprovided minor compile fixes and a CGI content map fix
856df5be573Smrg.It
857c9283f11Swiz.An Steve Rumble
858c9283f11Swiz.Aq Mt rumble@ephemeral.org
8599240578fSmrgprovided the
8609240578fSmrg.Fl V
8619b91523eSmrgoption
8629240578fSmrg.It
8631bf054d1Smrg.An Jukka Ruohonen
8641bf054d1Smrg.Aq Mt jruoho@NetBSD.org
8651bf054d1Smrgprovided support for
8661bf054d1Smrg.Xr blocklistd 8
8671bf054d1Smrg.It
868c9283f11Swiz.An Thor Lancelot Simon
869c9283f11Swiz.Aq Mt tls@NetBSD.org
8709b91523eSmrgenhanced cgi-bin support
871a4b84ca0Smrg.It
872c9283f11Swiz.An Joerg Sonnenberger
873c9283f11Swiz.Aq Mt joerg@NetBSD.org
87403387632Smrgimplemented If-Modified-Since support
87503387632Smrg.It
876a041bb87Skim.An Kimmo Suominen
877a041bb87Skim.Aq Mt kim@NetBSD.org
878a041bb87Skimremoved obsolete
879a041bb87Skim.Pa .bzdirect
880a041bb87Skimhandling
881a041bb87Skim.It
882c9283f11Swiz.An ISIHARA Takanori
883c9283f11Swiz.Aq Mt ishit@oak.dti.ne.jp
8849240578fSmrgprovided a man page fix
8859240578fSmrg.It
886c9283f11Swiz.An Holger Weiss
887c9283f11Swiz.Aq Mt holger@CIS.FU-Berlin.DE
888ffa84063Swizprovided http authorization fixes
88903387632Smrg.It
890c9283f11Swiz.Aq Mt xs@kittenz.org
8919240578fSmrgprovided chroot and change-to-user support, and other various fixes
892560f0b4fSmrg.It
893560f0b4fSmrg.An S.P.Zeidler
894560f0b4fSmrg.Aq Mt spz@NetBSD.org
895560f0b4fSmrgfixed several SSL shutdown issues
896560f0b4fSmrg.It
8979b91523eSmrgCoyote Point provided various CGI fixes
8989240578fSmrg.El
8999240578fSmrg.Pp
9009240578fSmrgThere are probably others I have forgotten (let me know if you care)
90103387632Smrg.Pp
90203387632SmrgPlease send all updates to
90303387632Smrg.Nm
90403387632Smrgto
905ab3f0bd6Smrg.Aq Mt mrg@eterna23.net
906ab3f0bd6Smrgor
907ab3f0bd6Smrg.Aq Mt netbsd-bugs@NetBSD.org
908f29f0747Sryoonfor inclusion in future releases.
9099240578fSmrg.Sh BUGS
9109240578fSmrg.Nm
91117ab36f1Smbalmerdoes not handle HTTP/1.1 chunked input from the client yet.
912