HTTPD.CONF(5) | File Formats Manual | HTTPD.CONF(5) |
httpd.conf
— HTTP
daemon configuration file
httpd.conf
is the configuration file for
the HTTP daemon, httpd(8).
httpd.conf
is divided into four main
sections:
Within the sections, a host address can be specified by IPv4 address, IPv6 address, interface name, interface group, or DNS hostname. If the address is an interface name, httpd(8) will look up the first IPv4 address and any other IPv4 and IPv6 addresses of the specified network interface. If ‘*’ is given as an address, it will be used as an alias for 0.0.0.0 to listen on all IPv4 addresses. Likewise, ‘::’ can be used to listen on all IPv6 addresses. A port can be specified by number or name. The port name to number mappings are found in the file /etc/services; see services(5) for details.
The current line can be extended over multiple lines using a backslash (‘\’). Comments can be put anywhere in the file using a hash mark (‘#’), and extend to the end of the current line. Care should be taken when commenting out multi-line text: the comment is effective until the end of the entire block.
Argument names not beginning with a letter, digit, or underscore must be quoted.
Additional configuration files can be included with the
include
keyword, for example:
include "/etc/httpd.conf.local"
Macros can be defined that will later be expanded in context.
Macro names must start with a letter, digit, or underscore, and may contain
any of those characters. Macro names may not be reserved words (for example,
directory
, log
, or
root
). Macros are not expanded inside quotes.
For example:
ext_ip="10.0.0.1" server "default" { listen on $ext_ip port 80 }
Here are the settings that can be set globally:
chroot
directorydefault
type
type/subtypelogdir
directoryprefork
numberThe configured web servers.
Each server
section starts with a
declaration of the server name:
server
name {...}server match
name {...}Followed by a block of options that is enclosed in curly brackets:
alias
namealias match
namealias
option, but
match
the name using pattern
matching instead of shell globbing rules, see
patterns(7).no
] authenticate
[realm] with
htpasswdchroot
and must be readable by the www user. Use
the no authenticate
directive to disable
authentication in a location.block drop
block
[return
code
[uri]]The uri may contain predefined macros that will be expanded at runtime:
$DOCUMENT_URI
$QUERY_STRING
$REMOTE_ADDR
$REMOTE_PORT
$REMOTE_USER
$REQUEST_URI
$SERVER_ADDR
$SERVER_PORT
$SERVER_NAME
location match
option.connection
optionmax request
body
numbermax
requests
numbertimeout
secondsdefault
type
type/subtypedirectory
optionno
] auto index
index
stringno
index
no
] fastcgi
[socket
socket]hsts
[option]max-age
secondspreload
subdomains
listen
on
address [tls
]
port
numberlocation
path {...}connection
,
listen on
, location
and
tcp
.location match
path
{...}location
option, but
match
the path using pattern
matching instead of shell globbing rules, see
patterns(7). The pattern
may contain captures that can be used in the uri of
an enclosed block return
option.no
] log
[option]access
and error
log files, but can be changed per server or location. Use the
no log
directive to disable logging of any
requests. Valid options are:
access
nameerror
namestyle
stylecommon
, combined
or
connection
. The styles
common
and combined
write a log entry after each request similar to the standard Apache
and nginx access log formats. The style
connection
writes a summarized log entry after
each connection, that can have multiple requests, similar to the
format that is used by
relayd(8). If not
specified, the default is common
.no
] syslog
pass
block
in a location.root
optionhttpd
. If not specified, it
defaults to /htdocs.strip
numbertcp
optionbacklog
numberip
minttl
numberip
ttl
numberno
] nodelay
no
] sack
socket
buffer
numbertls
optioncertificate
fileciphers
stringdhe
paramsecdhe
curvekey
filehttpd
. The default is
/etc/ssl/private/server.key.protocols
stringConfigure the supported media types.
httpd(8) will set the
Content-Type of the response header based on the file
extension listed in the types
section. If not
specified, httpd(8) will use
built-in media types for text/css,
text/html, text/plain,
image/gif, image/png,
image/jpeg, and
application/javascript.
The types
section must include one or more
lines of the following syntax:
include
fileThe following example will start one server that is pre-forked two times and is listening on all local IP addresses. It additionally defines some media types overriding the defaults.
prefork 2 server "default" { listen on * port 80 } types { text/css css text/html html htm text/txt txt image/gif gif image/jpeg jpeg jpg image/png png application/javascript js application/xml xml }
The server can also be configured to only listen on the primary IP address of the network interface that is a member of the "egress" group.
server "default" { listen on egress port 80 }
Multiple servers can be configured to support hosting of different
domains. If the same address is repeated multiple times in the
listen on
statement, the server will be matched
based on the requested host name.
server "www.example.com" { alias "example.com" listen on * port 80 listen on * tls port 443 root "/htdocs/www.example.com" } server "www.a.example.com" { listen on 203.0.113.1 port 80 root "/htdocs/www.a.example.com" } server "www.b.example.com" { listen on 203.0.113.1 port 80 root "/htdocs/www.b.example.com" } server "intranet.example.com" { listen on 10.0.0.1 port 80 root "/htdocs/intranet.example.com" }
Simple redirections can be configured with the
block
directive:
server "example.com" { listen on 10.0.0.1 port 80 block return 301 "http://www.example.com/" } server "www.example.com" { listen on 10.0.0.1 port 80 }
The httpd(8) program was written by Reyk Floeter <reyk@openbsd.org>.
July 19, 2015 | OpenBSD-5.9 |