aboutsummaryrefslogtreecommitdiff
path: root/modules/caddy.nix
blob: f82c7f0dd0d878625a71a5307698c3afbb36d186 (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
{ ... }:

# Caddy reverse proxy with automatic HTTPS (Let's Encrypt).
# All app ports are bound to 127.0.0.1; only Caddy listens on 80/443.
{
  services.caddy = {
    enable = true;
    email = "me@karanj.com";

    virtualHosts = {

      # AdGuard Home web UI, plus the HTTP-01 webroot for the independent
      # ACME cert AdGuard uses for its own DoH/DoT TLS (modules/acme.nix).
      "dns.karanj.com" = {
        extraConfig = ''
          handle /.well-known/acme-challenge/* {
            root * /var/lib/acme/acme-challenge
            file_server
          }
          handle {
            reverse_proxy 127.0.0.1:3000
          }
        '';
      };

      # Miniflux RSS reader
      "rss.karanj.com" = {
        extraConfig = ''
          reverse_proxy 127.0.0.1:8080
        '';
      };

      # Actual Budget
      "budget.karanj.com" = {
        extraConfig = ''
          reverse_proxy 127.0.0.1:5006
        '';
      };

      # cgit - public read-only git viewer + smart HTTP for git clone/pull.
      # Both cgit browsing and git-http-backend (clone/pull) are served by
      # the same nginx vhost on 8086 - nginx itself routes between them by
      # matching the request path, so a single proxy here covers both.
      "git.karanj.com" = {
        extraConfig = ''
          reverse_proxy 127.0.0.1:8086
        '';
      };

    };
  };
}