HTTPD.CONF(5)

NAME
httpd.conf - HTTP daemon configuration file

DESCRIPTION
httpd.conf is the configuration file for the HTTP daemon, httpd(8).

SECTIONS
httpd.conf is divided into four main sections:

Macros
    User-defined variables may be defined and used later, simplifying the configuration file.

Global Configuration
    Global settings for httpd(8).

Servers
    Listening HTTP web servers.

Types
    Media types and extensions.

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. 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
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, table, relay, or timeout). Macros are not expanded inside quotes.

For example:

    ext_ip="10.0.0.1"
    server "default" {
    	listen on $ext_ip port 80
    }

GLOBAL CONFIGURATION
Here are the settings that can be set globally:

prefork number
    Run the specified number of server processes. This increases the performance and prevents delays when connecting to a server. httpd(8) runs 3 server processes by default.

chroot directory
    Set the chroot(2) directory. If not specified, it defaults to /var/www, the home directory of the www user.

SERVERS
The configured web servers.

Each server must have a name and include one or more lines of the following syntax:

connection option
    Set the specified options and limits for HTTP connections. Valid options are:

    max request body number
        Set the maximum body size in bytes that the client can send to the server. The default value is 1048576 bytes (1M).

    max requests number
        Set the maximum number of requests per persistent HTTP connection. Persistent connections are negotiated using the Keep-Alive header in HTTP/1.0 and enabled by default in HTTP/1.1. The default maximum number of requests per connection is 100.

    timeout seconds
        Specify the inactivity timeout in seconds for accepted sessions. The default timeout is 600 seconds (10 minutes). The maximum is 2147483647 seconds (68 years).

directory option
    Set the specified options when serving or accessing directories. Valid options are:

    [no] auto index
        If no index file is found, automatically generate a directory listing. This is disabled by default.

    index string
        Set the directory index file. If not specified, it defaults to index.html.

    no index
        Disable the directory index. httpd will neither display nor generate a directory index.

[no] fastcgi [socket socket]
    Enable FastCGI instead of serving files. The socket is a local path name within the chroot(2) root directory of httpd and defaults to /run/slowcgi.sock.

listen on address [ssl] port number
    Set the listen address and port.

location path { ... }
    Specify server configuration rules for a specific location. The path argument will be matched against the URL path with shell globbing rules. A location section may include most of the server configuration rules except connection, listen on, location and tcp.

[no] log [option]
    Set the specified logging options. Logging is enabled by default using the standard 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 name
        Set the name of the access log file relative to the log directory. If not specified, it defaults to access.log.

    error name
        Set the name of the error log file relative to the log directory. If not specified, it defaults to error.log.

    style style
        Set the logging style. The style can be common, 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
        Enable or disable logging to syslog instead of the log files.

root directory
    Set the document root of the server. The directory is a pathname within the chroot(2) root directory of httpd. If not specified, it defaults to /htdocs.

ssl option
    Set the SSL configuration for the server. These options are only used if SSL has been enabled via the listen directive. Valid options are:

    certificate file
        Specify the certificate to use for this server. The file should contain a PEM encoded certificate.

    ciphers string
        Specify the SSL cipher string. If not specified, the default value HIGH:!aNULL will be used (strong crypto cipher suites without anonymous DH). See the CIPHERS section of openssl(1) for information about SSL cipher suites and preference lists.

    key file
        Specify the private key to use for this server. The file should contain a PEM encoded private key and reside outside of the chroot(2) root directory of httpd.

tcp option
    Enable or disable the specified TCP/IP options; see tcp(4) and ip(4) for more information about the options. Valid options are:

    backlog number
        Set the maximum length the queue of pending connections may grow to. The backlog option is 10 by default and is limited by the kern.somaxconn sysctl(8) variable.

    ip minttl number
        This option for the underlying IP connection may be used to discard packets with a TTL lower than the specified value. This can be used to implement the Generalized TTL Security Mechanism (GTSM) according to RFC 5082.

    ip ttl number
        Change the default time-to-live value in the IP headers.

        [no] nodelay Enable the TCP NODELAY option for this connection. This is recommended to avoid delays in the relayed data stream, e.g. for SSH connections.

        [no] sack Use selective acknowledgements for this connection.

    socket buffer number
        Set the socket-level buffer size for input and output for this connection. This will affect the TCP window size.

TYPES
Configure the supported media types. httpd will set the Content-Type of the response header based on the file extension listed in the types section. If not specified, httpd 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:

type/subtype name [name ...];
    Set the media type and subtype to the specified extension name. One or more names can be specified per line.

EXAMPLES
The following example will start one server that is pre-forked two times and listening on the primary IP address of the network interface that is a member of the egress group. It additionally defines some media types overriding the defaults.

    prefork 2
    server "default" {
    	listen on egress port 80
    }
    types {
    	text/css			css;
    	text/html			htm html;
    	text/txt			txt;
    	image/gif			gif;
    	image/jpeg			jpg jpeg;
    	image/png			png;
    	application/javascript		js;
    	application/xml			xml;
    }

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.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"
    }

The syntax of the types section is compatible with the format used by nginx(8), so it is possible to include its mime.types file directly:

    include "/etc/nginx/mime.types"

SEE ALSO
httpd(8)

AUTHORS
-nosplit The httpd(8) program was written by Reyk Floeter <reyk@openbsd.org>.