Caddy
services.caddy.acmeCA
::: {.note}
Sets the acme_ca
option
in the global options block of the resulting Caddyfile.
:::
The URL to the ACME CA's directory. It is strongly recommended to set
this to https://acme-staging-v02.api.letsencrypt.org/directory
for
Let's Encrypt's staging endpoint
while testing or in development.
Value null
should be prefered for production setups,
as it omits the acme_ca
option to enable
automatic issuer fallback.
Type: null or string
Default
null
Example
"https://acme-v02.api.letsencrypt.org/directory"
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.adapter
Name of the config adapter to use. See https://caddyserver.com/docs/config-adapters for the full list.
If null
is specified, the --adapter
argument is omitted when
starting or restarting Caddy. Notably, this allows specification of a
configuration file in Caddy's native JSON format, as long as the
filename does not start with Caddyfile
(in which case the caddyfile
adapter is implicitly enabled). See
https://caddyserver.com/docs/command-line#caddy-run for details.
::: {.note}
Any value other than null
or caddyfile
is only valid when providing
your own configFile
.
:::
Type: null or string
Default
if ((cfg.configFile != configFile) || (builtins.baseNameOf cfg.configFile) == "Caddyfile") then "caddyfile" else null
Example
nginx
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.configFile
Override the configuration file used by Caddy. By default, NixOS generates one automatically.
The configuration file is exposed at {file}/etc/caddy/caddy_config
.
Type: path
Default
"A Caddyfile automatically generated by values from services.caddy.*"
Example
`#!nix pkgs.writeText "Caddyfile" '' example.com
root * /var/www/wordpress php_fastcgi unix//run/php/php-version-fpm.sock file_server ''; `
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.dataDir
The data directory for caddy.
::: {.note} If left as the default value this directory will automatically be created before the Caddy server starts, otherwise you are responsible for ensuring the directory exists with appropriate ownership and permissions.
Caddy v2 replaced CADDYPATH
with XDG directories.
See https://caddyserver.com/docs/conventions#file-locations.
:::
Type: path
Default
"/var/lib/caddy"
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.email
Your email address. Mainly used when creating an ACME account with your CA, and is highly recommended in case there are problems with your certificates.
Type: null or string
Default
null
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.enable
Whether to enable Caddy web server.
Type: boolean
Default
false
Example
true
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.enableReload
Reload Caddy instead of restarting it when configuration file changes.
Note that enabling this option requires the admin API to not be turned off.
If you enable this option, consider setting grace_period
to a non-infinite value in {option}services.caddy.globalConfig
to prevent Caddy waiting for active connections to finish,
which could delay the reload essentially indefinitely.
Type: boolean
Default
true
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.extraConfig
Additional lines of configuration appended to the automatically
generated Caddyfile
.
Type: strings concatenated with "\n"
Default
""
Example
'' example.com { encode gzip log root /srv/http }''
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.globalConfig
Additional lines of configuration appended to the global config section
of the Caddyfile
.
Refer to https://caddyserver.com/docs/caddyfile/options#global-options for details on supported values.
Type: strings concatenated with "\n"
Default
""
Example
'' debug servers { protocol { experimental_http3 } }''
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.group
Group account under which caddy runs.
::: {.note} If left as the default value this user will automatically be created on system activation, otherwise you are responsible for ensuring the user exists before the Caddy service starts. :::
Type: string
Default
"caddy"
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.logDir
Directory for storing Caddy access logs.
::: {.note} If left as the default value this directory will automatically be created before the Caddy server starts, otherwise the sysadmin is responsible for ensuring the directory exists with appropriate ownership and permissions. :::
Type: path
Default
"/var/log/caddy"
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.logFormat
Configuration for the default logger. See https://caddyserver.com/docs/caddyfile/options#log for details.
Type: strings concatenated with "\n"
Default
'' level ERROR''
Example
mkForce "level INFO";
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.package
The caddy package to use.
Type: package
Default
pkgs.caddy
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.resume
Use saved config, if any (and prefer over any specified configuration passed with --config
).
Type: boolean
Default
false
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.settings
Structured configuration for Caddy to generate a Caddy JSON configuration file. See https://caddyserver.com/docs/json/ for available options.
::: {.warning} Using a Caddyfile instead of a JSON config is highly recommended by upstream. There are only very few exception to this.
Please use a Caddyfile via {option}services.caddy.configFile
, {option}services.caddy.virtualHosts
or
{option}services.caddy.extraConfig
with {option}services.caddy.globalConfig
instead.
:::
::: {.note}
Takes presence over most services.caddy.*
options, such as {option}services.caddy.configFile
and {option}services.caddy.virtualHosts
, if specified.
:::
Type: JSON value
Default
{ }
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.user
User account under which caddy runs.
::: {.note} If left as the default value this user will automatically be created on system activation, otherwise you are responsible for ensuring the user exists before the Caddy service starts. :::
Type: string
Default
"caddy"
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.virtualHosts
Declarative specification of virtual hosts served by Caddy.
Type: attribute set of (submodule)
Default
{ }
Example
{"hydra.example.com" = {serverAliases = [ "www.hydra.example.com" ];extraConfig = '' encode gzip root /srv/http '';};};
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.virtualHosts.<name>.extraConfig
Additional lines of configuration appended to this virtual host in the
automatically generated Caddyfile
.
Type: strings concatenated with "\n"
Default
""
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.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/caddy/default.nix
services.caddy.virtualHosts.<name>.listenAddresses
A list of host interfaces to bind to for this virtual host.
Type: list of string
Default
[ ]
Example
["127.0.0.1""::1"]
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.virtualHosts.<name>.logFormat
Configuration for HTTP request logging (also known as access logs). See https://caddyserver.com/docs/caddyfile/directives/log#log for details.
Type: strings concatenated with "\n"
Default
'' output file ''${config.services.caddy.logDir}/access-''${hostName}.log''
Example
mkForce '' output discard'';
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.virtualHosts.<name>.serverAliases
Additional names of virtual hosts served by this virtual host configuration.
Type: list of string
Default
[ ]
Example
["www.example.org""example.org"]
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/web-servers/caddy/default.nix
services.caddy.virtualHosts.<name>.useACMEHost
A host of an existing Let's Encrypt certificate to use. This is mostly useful if you use DNS challenges but Caddy does not currently support your provider.
Note that this option does not create any certificates, nor does it 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/caddy/default.nix