Skip to content

Httpd

services.httpd.adminAddr

E-mail address of the server administrator. Type: null or string

Default

null

Example

"admin@example.org"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.configFile

Override the configuration file used by Apache. By default, NixOS generates one automatically.

Type: path

Default

confFile

Example

pkgs.writeText "httpd.conf" "# my custom config file ..."

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.enable

Whether to enable the Apache HTTP Server. Type: boolean

Default

false

Example

true

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.enableMellon

Whether to enable the mod_auth_mellon module. Type: boolean

Default

false

Example

true

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.enablePHP

Whether to enable the PHP module. Type: boolean

Default

false

Example

true

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.enablePerl

Whether to enable the Perl module (mod_perl). Type: boolean

Default

false

Example

true

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.extraConfig

Configuration lines appended to the generated Apache configuration file. Note that this mechanism will not work when {option}configFile is overridden.

Type: strings concatenated with "\n"

Default

""

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.extraModules

Additional Apache modules to be used. These can be specified as a string in the case of modules distributed with Apache, or as an attribute set specifying the {var}name and {var}path of the module.

Type: list of unspecified value

Default

[ ]

Example

["proxy_connect"{ name = "jk"; path = "${pkgs.apacheHttpdPackages.mod_jk}/modules/mod_jk.so"; }]

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.group

Group under which httpd children processes run.

Type: string

Default

"wwwrun"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.logDir

Directory for Apache's log files. It is created automatically.

Type: path

Default

"/var/log/httpd"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.logFormat

Log format for log files. Possible values are: combined, common, referer, agent, none. See https://httpd.apache.org/docs/2.4/logs.html for more details.

Type: string

Default

"common"

Example

"combined"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.logPerVirtualHost

If enabled, each virtual host gets its own {file}access.log and {file}error.log, namely suffixed by the {option}hostName of the virtual host.

Type: boolean

Default

true

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.maxClients

Maximum number of httpd processes (prefork) Type: signed integer

Default

150

Example

8

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.maxRequestsPerChild

Maximum number of httpd requests answered per httpd child (prefork), 0 means unlimited.

Type: signed integer

Default

0

Example

500

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.mpm

Multi-processing module to be used by Apache. Available modules are prefork (handles each request in a separate child process), worker (hybrid approach that starts a number of child processes each running a number of threads) and event (the default; a recent variant of worker that handles persistent connections more efficiently).

Type: one of "event", "prefork", "worker"

Default

"event"

Example

"worker"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.package

The apacheHttpd package to use. Type: package

Default

pkgs.apacheHttpd

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.phpOptions

Options appended to the PHP configuration file {file}php.ini.

Type: strings concatenated with "\n"

Default

""

Example

'' date.timezone = "CET"''

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.phpPackage

The php package to use. Type: package

Default

pkgs.php

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.sslCiphers

Cipher Suite available for negotiation in SSL proxy handshake. Type: string

Default

"HIGH:!aNULL:!MD5:!EXP"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.sslProtocols

Allowed SSL/TLS protocol versions. Type: string

Default

"All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1"

Example

"All -SSLv2 -SSLv3"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.user

User account under which httpd children processes run.

If you require the main httpd process to run as root add the following configuration:

systemd.services.httpd.serviceConfig.User = lib.mkForce "root";

Type: string

Default

"wwwrun"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts

Specification of the virtual hosts served by Apache. Each element should be an attribute set specifying the configuration of the virtual host.

Type: attribute set of (submodule)

Default

{localhost = {documentRoot = "${package.out}/htdocs";};}

Example

{"foo.example.com" = {forceSSL = true;documentRoot = "/var/www/foo.example.com"};"bar.example.com" = {addSSL = true;documentRoot = "/var/www/bar.example.com";};}

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.acmeRoot

Directory for the acme challenge which is PUBLIC, don't put certs or keys in here. Set to null to inherit from config.security.acme.

Type: null or string

Default

"/var/lib/acme/acme-challenge"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.addSSL

Whether to enable HTTPS in addition to plain HTTP. This will set defaults for listen to listen on all interfaces on the respective default ports (80, 443).

Type: boolean

Default

false

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.adminAddr

E-mail address of the server administrator. Type: null or string

Default

null

Example

"admin@example.org"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.documentRoot

The path of Apache's document root directory. If left undefined, an empty directory in the Nix store will be used as root.

Type: null or path

Default

null

Example

"/data/webserver/docs"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.enableACME

Whether to ask Let's Encrypt to sign a certificate for this vhost. Alternately, you can use an existing certificate through {option}useACMEHost.

Type: boolean

Default

false

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.enableUserDir

Whether to enable serving {file}~/public_html as /~«username».

Type: boolean

Default

false

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.extraConfig

These lines go to httpd.conf verbatim. They will go after directories and directory aliases defined by default.

Type: strings concatenated with "\n"

Default

""

Example

'' <Directory /home> Options FollowSymlinks AllowOverride All </Directory>''

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.forceSSL

Whether to add a separate nginx server block that permanently redirects (301) all plain HTTP traffic to HTTPS. This will set defaults for listen to listen on all interfaces on the respective default ports (80, 443), where the non-SSL listens are used for the redirect vhosts.

Type: boolean

Default

false

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.globalRedirect

If set, all requests for this host are redirected permanently to the given URL.

Type: null or string

Default

null

Example

"http://newserver.example.org/"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.hostName

Canonical hostname for the server. Type: string

Default

"‹name›"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.http2

Whether to enable HTTP 2. HTTP/2 is supported in all multi-processing modules that come with httpd. However, if you use the prefork mpm, there will be severe restrictions. Refer to https://httpd.apache.org/docs/2.4/howto/http2.html#mpm-config for details.

Type: boolean

Default

true

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.listen

Listen addresses and ports for this virtual host.

::: {.note} This option overrides addSSL, forceSSL and onlySSL.

If you only want to set the addresses manually and not the ports, take a look at listenAddresses. :::

Type: list of (submodule)

Default

[ ]

Example

[{ip = "195.154.1.1";port = 443;ssl = true;}{ip = "192.154.1.1";port = 80;}{ip = "*";port = 8080;}]

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.listen.*.ip

IP to listen on. 0.0.0.0 for IPv4 only, * for all. Type: string

Default

"*"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.listen.*.port

Port to listen on Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.listen.*.ssl

Whether to enable SSL (https) support. Type: boolean

Default

false

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.listenAddresses

Listen addresses for this virtual host. Compared to listen this only sets the addresses and the ports are chosen automatically.

Type: non-empty (list of string)

Default

["*"]

Example

["127.0.0.1"]

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.locations

Declarative location config. See https://httpd.apache.org/docs/2.4/mod/core.html#location for details.

Type: attribute set of (submodule)

Default

{ }

Example

{"/" = {proxyPass = "http://localhost:3000";};"/foo/bar.png" = {alias = "/home/eelco/some-file.png";};};

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.locations.<name>.alias

Alias directory for requests. See https://httpd.apache.org/docs/2.4/mod/mod_alias.html#alias.

Type: null or path

Default

null

Example

"/your/alias/directory"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.locations.<name>.extraConfig

These lines go to the end of the location verbatim.

Type: strings concatenated with "\n"

Default

""

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.locations.<name>.index

Adds DirectoryIndex directive. See https://httpd.apache.org/docs/2.4/mod/mod_dir.html#directoryindex.

Type: null or string

Default

null

Example

"index.php index.html"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.locations.<name>.priority

Order of this location block in relation to the others in the vhost. The semantics are the same as with lib.mkOrder. Smaller values have a greater priority.

Type: signed integer

Default

1000

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.locations.<name>.proxyPass

Sets up a simple reverse proxy as described by https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html#simple.

Type: null or string

Default

null

Example

"http://www.example.org/"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.logFormat

Log format for Apache's log files. Possible values are: combined, common, referer, agent.

Type: string

Default

"common"

Example

"combined"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.onlySSL

Whether to enable HTTPS and reject plain HTTP connections. This will set defaults for listen to listen on all interfaces on port 443.

Type: boolean

Default

false

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.robotsEntries

Specification of pages to be ignored by web crawlers. See http://www.robotstxt.org/ for details.

Type: strings concatenated with "\n"

Default

""

Example

"Disallow: /foo/"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.servedDirs

This option provides a simple way to serve static directories.

Type: list of (attribute set)

Default

[ ]

Example

[{dir = "/home/eelco/Dev/nix-homepage";urlPath = "/nix";}]

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.servedFiles

This option provides a simple way to serve individual, static files.

::: {.note} This option has been deprecated and will be removed in a future version of NixOS. You can achieve the same result by making use of the locations.<name>.alias option. :::

Type: list of (attribute set)

Default

[ ]

Example

[{file = "/home/eelco/some-file.png";urlPath = "/foo/bar.png";}]

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.serverAliases

Additional names of virtual hosts served by this virtual host configuration.

Type: list of string

Default

[ ]

Example

["www.example.org""www.example.org:8080""example.org"]

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.sslServerCert

Path to server SSL certificate. Type: path

Example

"/var/host.cert"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.sslServerChain

Path to server SSL chain file. Type: null or path

Default

null

Example

"/var/ca.pem"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.sslServerKey

Path to server SSL certificate key. Type: path

Example

"/var/host.key"

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix

services.httpd.virtualHosts.<name>.useACMEHost

A host of an existing Let's Encrypt certificate to use. This is useful if you have many subdomains and want to avoid hitting the rate limit. Alternately, you can generate a certificate through {option}enableACME. Note that this option does not create any certificates, nor it does add subdomains to existing ones – you will need to create them manually using .

Type: null or string

Default

null

Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/apache-httpd/default.nix