summary refs log tree commit diff
path: root/nixos/modules/services/web-servers/caddy/vhost-options.nix
blob: f240ec605c2930950eb5504f8ea5421f2e004974 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{ cfg }:
{ config, lib, name, ... }:
let
  inherit (lib) literalExpression mkOption types;
in
{
  options = {

    hostName = mkOption {
      type = types.str;
      default = name;
      description = "Canonical hostname for the server.";
    };

    serverAliases = mkOption {
      type = with types; listOf str;
      default = [ ];
      example = [ "www.example.org" "example.org" ];
      description = ''
        Additional names of virtual hosts served by this virtual host configuration.
      '';
    };

    listenAddresses = mkOption {
      type = with types; listOf str;
      description = ''
        A list of host interfaces to bind to for this virtual host.
      '';
      default = [ ];
      example = [ "127.0.0.1" "::1" ];
    };

    useACMEHost = mkOption {
      type = types.nullOr types.str;
      default = null;
      description = ''
        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.

        <emphasis>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 <xref linkend="opt-security.acme.certs"/>. Additionally,
        you should probably add the <literal>caddy</literal> user to the
        <literal>acme</literal> group to grant access to the certificates.</emphasis>
      '';
    };

    logFormat = mkOption {
      type = types.lines;
      default = ''
        output file ${cfg.logDir}/access-${config.hostName}.log
      '';
      defaultText = ''
        output file ''${config.services.caddy.logDir}/access-''${hostName}.log
      '';
      example = literalExpression ''
        mkForce '''
          output discard
        ''';
      '';
      description = ''
        Configuration for HTTP request logging (also known as access logs). See
        <link xlink:href="https://caddyserver.com/docs/caddyfile/directives/log#log"/>
        for details.
      '';
    };

    extraConfig = mkOption {
      type = types.lines;
      default = "";
      description = ''
        Additional lines of configuration appended to this virtual host in the
        automatically generated <literal>Caddyfile</literal>.
      '';
    };

  };
}