1 .\" $NetBSD: bozohttpd.8,v 1.53 2015/08/13 12:30:08 wiz Exp $
3 .\" $eterna: bozohttpd.8,v 1.101 2011/11/18 01:25:11 mrg Exp $
5 .\" Copyright (c) 1997-2015 Matthew R. Green
6 .\" All rights reserved.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
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
19 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
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
34 .Nd hyper text transfer protocol version 1.1 daemon
38 .Op Fl C Ar suffix cgihandler
40 .Op Fl L Ar prefix script
41 .Op Fl M Ar suffix type encoding encoding11
43 .Op Fl S Ar server_software
44 .Op Fl Z Ar cert privkey
49 .Op Fl v Ar virtualroot
58 request from the standard input, and sends a reply to the standard output.
59 Besides ~user translation and virtual hosting support (see below), all file
65 as its name, which defaults to the local hostname, obtained from
69 option for virtual hosting.)
73 using the ftp facility (but see the
77 is designed to be small, simple and relatively featureless,
78 hopefully increasing its security.
80 The following options are available:
81 .Bl -tag -width xxxcgibin
83 Enables daemon mode, where
85 detaches from the current terminal, running in the background and
86 servicing HTTP requests.
87 .It Fl C Ar suffix cgihandler
88 Adds a new CGI handler program for a particular file type.
91 should be any normal file suffix, and the
93 should be a full path to an interpreter.
94 This option is the only way to enable CGI programs that exist
95 outside of the cgibin directory to be executed.
98 options may be passed.
100 Enables the CGI/1.1 interface.
103 directory is expected to contain the CGI programs to be used.
105 looks for URL's in the form of
106 .Em /cgi-bin/\*[Lt]scriptname\*[Gt]
109 is a valid CGI program in the
112 In other words, all CGI URL's must begin with
114 Note that the CGI/1.1 interface is not available with
120 to not clear the environment when used with either the
130 detaching from the tty and going into the background.
132 Causes directory index mode to hide files and directories
133 that start with a period, except for
142 instead of the default
147 option, it changes the bound port.
148 Otherwise it forces redirections to use this port instead of the
154 to be used as the address to bind daemon mode.
155 If otherwise unspecified, the address used to bind is derived from the
157 which defaults to the name returned by
162 This option is only valid with the
165 .It Fl L Ar prefix script
166 Adds a new Lua script for a particular prefix.
169 should be an arbitrary text, and the
171 should be a full path to a Lua script.
174 options may be passed.
175 A separate Lua state is created for each prefix.
176 The Lua script can register callbacks using the
177 httpd.register_handler('<name>', function) Lua function,
178 which will trigger the execution of the Lua function
180 when a URL in the form
181 .Em http://<hostname>/<prefix>/<name>
183 The function is passed three tables as arguments, the server
184 environment, the request headers, and the decoded query string
185 plus any data that was send as application/x-www-form-urlencoded.
186 .It Fl M Ar suffix type encoding encoding11
187 Adds a new entry to the table that converts file suffixes to
188 content type and encoding.
189 This option takes four additional arguments containing
192 .Dq Content-Encoding ,
195 for HTTP/1.1 connections, respectively.
196 If any of these are a single dash
198 the empty string is used instead.
201 options may be passed.
205 from doing IP address to name resolution of hosts for setting the
207 variable before running a CGI program.
208 This option has no effect without the
214 to create a pid file in
216 when run in daemon mode with the
220 Changes the default user directory for
227 Forces pages besides the
231 option) page to require that the Referrer: header be present and
232 refer to this web server, otherwise a redirect to the
234 page will be returned instead.
235 .It Fl S Ar server_software
236 Sets the internal server version to
237 .Ar server_software .
239 Forces logging to be set to stderr always.
240 .It Fl t Ar chrootdir
243 chroot to the specified directory
244 before answering requests.
245 Every other path should be specified relative
246 to the new root, if this option is used.
247 Note that the current environment
248 is normally replaced with an empty environment with this option, unless the
254 to switch to the user and the groups of
256 after initialization.
261 to clear the environment unless the
265 Enables the transformation of Uniform Resource Locators of
269 .Pa ~user/public_html
274 Sets the default virtual host directory to
276 If no directory exists in
278 for the request, then
281 The default behaviour is to return 404 (Not Found.)
282 .It Fl v Ar virtualroot
283 Enables virtual hosting support.
286 will be searched for a matching virtual host name, when parsing
288 If a matching name is found, it will be used
289 as both the server's real name,
295 section for an example of using this option.
297 Enables directory indexing.
298 A directory index will be generated only when the default file (i.e.
300 normally) is not present.
302 Changes the default file read for directories from
306 .It Fl Z Ar certificate_path privatekey_path
307 Sets the path to the server certificate file and the private key file
316 versions 20031005 and prior that supported the
320 options, they took a single space-separated argument that was parsed.
321 since version 20040828, they take multiple options (2 in the case of
325 .Ss INETD CONFIGURATION
330 by default to process incoming TCP connections for HTTP requests
335 has little internal networking knowledge.
336 (Indeed, you can run it on the command line with little change of functionality.)
341 http stream tcp nowait:600 _httpd /usr/libexec/httpd httpd /var/www
342 http stream tcp6 nowait:600 _httpd /usr/libexec/httpd httpd /var/www
345 This would serve web pages from
347 on both IPv4 and IPv6 ports.
351 requests per minute to 600, up from the
358 you can provide multiple IP-address based HTTP servers by having multiple
359 listening ports with different configurations.
361 This server supports the
367 Support for these protocols is very minimal and many optional features are
371 can be compiled without
372 CGI support (NO_CGIBIN_SUPPORT),
373 user transformations (NO_USER_SUPPORT),
374 directory index support (NO_DIRINDEX_SUPPORT),
375 daemon mode support (NO_DAEMON_MODE),
376 dynamic MIME content (NO_DYNAMIC_CONTENT),
377 Lua suport (NO_LUA_SUPPORT),
378 and SSL support (NO_SSL_SUPPORT)
379 by defining the listed macros when building
381 .Ss HTTP BASIC AUTHORISATION
383 has support for HTTP Basic Authorisation.
386 exists in the directory of the current request,
388 will restrict access to documents in that directory
389 using the RFC 2617 HTTP
391 authentication scheme.
394 This does not recursively protect any sub-directories.
398 file contains lines delimited with a colon containing
399 usernames and passwords hashed with
403 heather:$1$pZWI4tH/$DzDPl63i6VvVRv2lJNV7k1
411 utility may be used to generate hashed passwords.
417 has support for HTTP Basic Authorisation enabled by default,
418 in the portable distribution it is excluded.
423 on the compiler command line to enable this support.
424 It may require linking with the crypt library, using
428 has support for SSLv2, SSLv3, and TLSv1 protocols that is included by
430 It requires linking with the crypto and ssl library, using
432 To disable SSL SUPPORT compile
436 on the compiler command line.
439 supports a very basic form compression.
441 will serve the requested file postpended with
443 if it exists, it is readable, the client requested gzip compression, and
444 the client did not make a ranged request.
447 looks for a couple of special files in directories that allow certain features
448 to be provided on a per-directory basis.
451 used by HTTP basic authorisation,
454 file is found (contents are irrelevant)
456 will allow direct access even with the
461 symbolic link is found,
463 will perform a smart redirect to the target of this symlink.
464 The target is assumed to live on the same server.
467 symbolic link is found,
469 will redirect to the absolute url pointed to by this symlink.
470 This is useful to redirect to different servers.
472 To configure set of virtual hosts, one would use an
476 http stream tcp nowait:600 _httpd /usr/libexec/httpd httpd -v /var/vroot /var/www
481 create a directory (or a symlink to a directory) with the same name as
482 the virtual host, for each virtual host.
483 Lookups for these names are done in a case-insensitive manner, and may
484 include the port number part of the request, allowing for distinct
485 virtual hosts on the same name.
489 with PHP, one must use the
491 option to specify a CGI handler for a particular file type.
492 Typically this will be like:
494 httpd -C .php /usr/pkg/bin/php /var/www
501 was first written in perl, based on another perl http server
504 It was then rewritten from scratch in perl, and then once again in C.
507 version 20060517, it has been integrated into
509 The focus has always been simplicity and security, with minimal features
510 and regular code audits.
511 This manual documents
519 .Aq Mt mrg@eterna.com.au .
521 The large list of contributors includes:
525 .Aq Mt mbalmer@NetBSD.org
526 added Lua support for dynamic content creation
530 provided Range: header support
533 .Aq Mt seanb@NetBSD.org
534 provided a security fix for virtual hosting
537 .Aq Mt jdc@coris.org.uk
538 provided an IPv6 bugfix
541 .Aq Mt chuck@research.att.com
542 provided cgi-bin support fixes, and more
544 .An Alistair G. Crooks
545 .Aq Mt agc@NetBSD.org
546 cleaned up many internal interfaces, made
548 linkable as a library and provided the Lua binding.
551 .Aq Mt degroote@NetBSD.org
552 provided a fix for daemon mode
556 provided directory indexing support
559 .Aq Mt pek@pdc.kth.se
560 provided a fix for a minor (non-security) buffer overflow condition
562 .An Roland Dowdeswell
563 .Aq Mt elric@NetBSD.org
564 added support for serving gzipped files and better SSL handling
566 .An Jun-ichiro itojun Hagino, KAME
567 .Aq Mt itojun@iijlab.net
568 provided initial IPv6 support
571 .Aq Mt martin@NetBSD.org
572 provided .bzabsredirect support, and fixed various redirection issues
575 .Aq Mt arto.huusko@pp2.inet.fi
576 provided fixes cgi-bin
579 .Aq Mt roland.illig@gmx.de
580 provided some off-by-one fixes
584 provided cgi-bin enhancements
588 provided fixes for HTTP basic authorisation support
591 .Aq Mt pooka@NetBSD.org
592 provided fixes for HTTP basic authorisation support
595 .Aq Mt wiz@NetBSD.org
596 provided many fixes and enhancements for the man page
598 .An Mateusz Kocielski
599 .Aq Mt shm@NetBSD.org
600 fixed memory leaks, various issues with userdir support,
601 information disclosure issues, added support for using CGI handlers
602 with directory indexing and provided various other fixes.
605 .Aq Mt alc@NetBSD.org
606 provided some clean up for memory leaks
609 .Aq Mt jlam@NetBSD.org
610 provided man page fixes
613 .Aq Mt jmmv@NetBSD.org
619 .Aq Mt lukem@NetBSD.org
620 provided many various fixes, including cgi-bin fixes and enhancements,
621 HTTP basic authorisation support and much code clean up
624 .Aq Mt rajeev_v_pillai@yahoo.com
625 provided several fixes for virtual hosting
628 .Aq Mt reed@NetBSD.org
629 provided several clean up fixes, and man page updates
632 .Aq Mt scottr@NetBSD.org
633 provided various fixes
636 .Aq Mt rtr@eterna.com.au
637 provided SSL support, cgi-bin fixes and much other random other stuff
641 provided minor compile fixes and a CGI content map fix
644 .Aq Mt rumble@ephemeral.org
649 .An Thor Lancelot Simon
650 .Aq Mt tls@NetBSD.org
651 enhanced cgi-bin support.
653 .An Joerg Sonnenberger
654 .Aq Mt joerg@NetBSD.org
655 implemented If-Modified-Since support
658 .Aq Mt ishit@oak.dti.ne.jp
659 provided a man page fix
662 .Aq Mt holger@CIS.FU-Berlin.DE
663 provided http authorisation fixes
665 .Aq Mt xs@kittenz.org
666 provided chroot and change-to-user support, and other various fixes
668 Coyote Point provided various CGI fixes.
671 added pidfile support and provided some man page fixes.
674 There are probably others I have forgotten (let me know if you care)
676 Please send all updates to
679 .Aq Mt mrg@eterna.com.au
680 for inclusion in future releases.
683 does not handle HTTP/1.1 chunked input from the client yet.