- NetBSD Manual Pages
HTTPD(8) NetBSD System Manager's Manual HTTPD(8)
Powered by man-cgi (2021-06-01).
Maintained for NetBSD
by Kimmo Suominen.
Based on man-cgi by Panagiotis Christias.
httpd -- hyper text transfer protocol version 1.1 daemon
httpd [-CIMPSZciptvx] [-C suffix cgihandler] [-I port]
[-M suffix type encoding encoding11] [-P pidfile]
[-S server_software] [-Z cert privkey] [-c cgibin] [-i address]
[-p pubdir] [-t chrootdir] [-v virtualroot] [-x index] slashdir
The httpd program reads a HTTP request from the standard input, and sends
a reply to the standard output. Besides ~user translation and virtual
hosting support (see below), all file requests are from slashdir direc-
tory. The server uses myname as its name, which defaults to the local
hostname, obtained from gethostname(3) (but see the -v option for virtual
hosting.) httpd writes logs to syslog(3) using the ftp facility (but see
the -s option for testing.) httpd is designed to be small, simple and
relatively featureless, hopefully increasing its security.
The following options are available:
-b Enables daemon mode, where httpd detaches from the current
terminal, running in the background and servicing HTTP
-C suffix cgihandler
Adds a new CGI handler program for a particular file type.
The suffix should be any normal file suffix, and the
cgihandler should be a full path to an interpreter. This
option is the only way to enable CGI programs that exist out-
side of the cgibin directory to be executed. Multiple -C
options may be passed.
-c cgibin Enables the CGI/1.1 interface. The cgibin directory is
expected to contain the CGI programs to be used. httpd looks
for URL's in the form of /cgi-bin/<scriptname> where
<scriptname> is a valid CGI program in the cgibin directory.
In other words, all CGI URL's must begin with /cgi-bin/. Note
that the CGI/1.1 interface is not available with ~user trans-
-e Causes httpd to not clear the environment when used with
either the -t or -U options.
-f Stops the -b flag from httpd detaching from the tty and going
into the background.
-H Causes directory index mode to hide files and directories that
start with a period, except for ... Also see -X.
-I port Causes httpd to use port instead of the default ``http'' port.
When used with the -b option, it changes the bound port. Oth-
erwise it forces redirections to use this port instead of the
value obtained via getsockname(2).
Causes address to use used as the address to bind daemon mode.
If otherwise unspecified, the address used to bind is derived
from the myname, which defaults to the name returned by
gethostname(3). Only the last -i option is used. This option
is only valid with the -b option.
-M suffix type encoding encoding11
Adds a new entry to the table that converts file suffixes to
content type and encoding. This option takes four additional
arguments containing the file prefix, its ``Content-Type'',
``Content-Encoding'', and ``Content-Encoding'' for HTTP/1.1
connections, respectively. If any of these are a single dash
(``-''), the empty string is used instead. Multiple -M
options may be passed.
-n Stops httpd from doing IP address to name resolution of hosts
for setting the REMOTE_HOST variable before running a CGI pro-
gram. This option has no effect without the -c option.
Causes httpd to create a pid file in pidfile when run in dae-
mon mode with the -b option.
-p pubdir Changes the default user directory for /~user/ translations
from ``public_html'' to pubdir.
-r Forces pages besides the ``index.html'' (see the -X option)
page to require that the Referrer: header be present and refer
to this web server, otherwise a redirect to the ``index.html''
page will be returned instead.
Sets the internal server version to server_software.
-s Forces logging to be set to stderr always.
Makes httpd chroot to the specified directory before answering
requests. Every other path should be specified relative to
the new root, if this option is used. Note that the current
environment is normally replaced with an empty environment
with this option, unless the -e option is also used.
Causes httpd to switch to the user and the groups of username
after initialization. This option, like -t above, causes
httpd to clear the environment unless the -e option is given.
-u Enables the transformation of Uniform Resource Locators of the
form /~user/ into the directory ~user/public_html (but see the
-p option above).
-V Sets the default virtual host directory to slashdir. If no
directory exists in virtualroot for the request, then slashdir
will be used. The default behaviour is to return 404 (Not
Enables virtual hosting support. Directories in virtualroot
will be searched for a matching virtual host name, when pars-
ing the HTML request. If a matching name is found, it will be
used as both the server's real name, [myname], and as the
slashdir. See the EXAMPLES section for an example of using
-X Enables directory indexing. A directory index will be gener-
ated only when the default file (i.e. index.html normally) is
-x index Changes the default file read for directories from
``index.html'' to index.
-Z certificate_path privatekey_path
Sets the path to the server certificate file and the private
key file in pem format. It also causes httpd to start SSL
Note that in httpd versions 20031005 and prior that supported the -C and
-M options, they took a single space-separated argument that was parsed.
since version 20040828, they take multiple options (2 in the case of -C
and 4 in the case of -M.)
As httpd uses inetd(8) by default to process incoming TCP connections for
HTTP requests (but see the -b option), httpd has little internal network-
ing knowledge. (Indeed, you can run it on the command line with little
change of functionality.) A typical inetd.conf(5) entry would be:
http stream tcp nowait:600 _httpd /usr/libexec/httpd httpd /var/www
http stream tcp6 nowait:600 _httpd /usr/libexec/httpd httpd /var/www
This would serve web pages from /var/www on both IPv4 and IPv6 ports.
The :600 changes the requests per minute to 600, up from the inetd(8)
default of 40.
Using the NetBSD inetd(8), you can provide multiple IP-address based HTTP
servers by having multiple listening ports with different configurations.
This server supports the HTTP/0.9, HTTP/1.0, and HTTP/1.1 standards.
Support for these protocols is very minimal and many optional features
are not supported.
httpd can be compiled without CGI support (NO_CGIBIN_SUPPORT), user
transformations (NO_USER_SUPPORT), directory index support
(NO_DIRINDEX_SUPPORT), daemon mode support (NO_DAEMON_MODE), and dynamic
MIME content (NO_DYNAMIC_CONTENT), and SSL support (NO_SSL_SUPPORT) by
defining the listed macros when building httpd.
HTTP BASIC AUTHORISATION
httpd has support for HTTP Basic Authorisation. If a file named
.htpasswd exists in the directory of the current request, httpd will
restrict access to documents in that directory using the RFC 2617 HTTP
``Basic'' authentication scheme.
Note: This does not recursively protect any sub-directories.
The .htpasswd file contains lines delimited with a colon containing user-
names and passwords hashed with crypt(3), for example:
On NetBSD, the pwhash(1) utility may be used to generate hashed pass-
While httpd distributed with NetBSD has support for HTTP Basic Authorisa-
tion enabled by default, in the portable distribution it is excluded.
Compile httpd with ``-DDO_HTPASSWD'' on the compiler command line to
enable this support. It may require linking with the crypt library,
httpd has support for SSLv2, SSLv3, and TLSv1 protocols that is included
by default. It requires linking with the crypto and ssl library, using
``-lcrypto -lssl''. To disable SSL SUPPORT compile httpd with
``-DNO_SSL_SUPPORT'' on the compiler command line.
httpd looks for a couple of special files in directories that allow cer-
tain features to be provided on a per-directory basis. In addition to
the .htpasswd used by HTTP basic authorisation, if a .bzdirect file is
found (contents are irrelevant) httpd will allow direct access even with
the -r option. If a .bzredirect symbolic link is found, httpd will per-
form a smart redirect to the target of this symlink. The target is
assumed to live on the same server. If a .bzabsredirect symbolic link is
found, httpd will redirect to the absolute url pointed to by this sym-
link. This is useful to redirect to different servers.
To configure set of virtual hosts, one would use an inetd.conf(5) entry
http stream tcp nowait:600 _httpd /usr/libexec/httpd httpd -v /var/vroot /var/www
and inside /var/vroot create a directory (or a symlink to a directory)
with the same name as the virtual host, for each virtual host. Lookups
for these names are done in a case-insensitive manner.
To use httpd with PHP, one must use the -C option to specify a CGI han-
dler for a particular file type. Typically this will be like:
httpd -C .php /usr/pkg/bin/php /var/www
The httpd program is actually called ``bozohttpd''. It was first written
in perl, based on another perl http server called ``tinyhttpd''. It was
then rewritten from scratch in perl, and then once again in C. From
``bozohttpd'' version 20060517, it has been integrated into NetBSD. The
focus has always been simplicity and security, with minimal features and
regular code audits. This manual documents httpd version 20100920.
httpd was written by Matthew R. Green <email@example.com>.
The large list of contributors includes:
- Arnaud Lacombe <firstname.lastname@example.org> provided some clean up for memory
- Christoph Badura <email@example.com> provided Range: header support
- Sean Boudreau <seanb@NetBSD.org> provided a security fix for virtual
- Julian Coleman <firstname.lastname@example.org> provided an IPv6 bugfix
- Chuck Cranor <email@example.com> provided cgi-bin support fixes,
- DEGROOTE Arnaud <firstname.lastname@example.org> provided a fix for daemon mode
- Andrew Doran <email@example.com> provided directory indexing support
- Per Ekman <firstname.lastname@example.org> provided a fix for a minor (non-security)
buffer overflow condition
- Alistair G. Crooks <email@example.com> cleaned up many internal inter-
faces, made bozohttpd linkable as a library and provided the lua
- Jun-ichiro itojun Hagino, KAME <firstname.lastname@example.org> provided initial
- Martin Husemann <email@example.com> provided .bzabsredirect support
- Arto Huusko <firstname.lastname@example.org> provided fixes cgi-bin
- Roland Illig <email@example.com> provided some off-by-one fixes
- Zak Johnson <firstname.lastname@example.org> provided cgi-bin enhancements
- Nicolas Jombart <email@example.com> provided fixes for HTTP basic autho-
- Thomas Klausner <firstname.lastname@example.org> provided many fixes
and enhancements for the man page
- Johnny Lam <email@example.com> provided man page fixes
- Luke Mewburn <firstname.lastname@example.org> provided many various fixes, includ-
ing cgi-bin fixes and enhancements, HTTP basic authorisation support
and much code clean up
- Jeremy C. Reed <email@example.com> provided several clean up fixes, and
man page updates
- Scott Reynolds <firstname.lastname@example.org> provided various fixes
- Tyler Retzlaff <email@example.com> provided SSL support, cgi-bin
fixes and much other random other stuff
- rudolf <firstname.lastname@example.org> provided minor compile fixes and a CGI content
- Steve Rumble <email@example.com> provided the -V option.
- Joerg Sonnenberger <firstname.lastname@example.org> implemented If-Modified-Since
- ISIHARA Takanori <email@example.com> provided a man page fix
- Holger Weiss <holger@CIS.FU-Berlin.DE> provided http authorisation
- <firstname.lastname@example.org> provided chroot and change-to-user support, and
other various fixes
- Coyote Point provided various CGI fixes
- Julio Merino added pidfile support and provided some man page fixes
There are probably others I have forgotten (let me know if you care)
Please send all updates to httpd to <email@example.com> for inclusion in
httpd does not handle HTTP/1.1 chunked input from the client yet.
NetBSD 6.0.1 November 17, 2011 NetBSD 6.0.1