summary refs log tree commit diff stats
path: root/system/services/keycloak/default.nix
blob: 981833fe8a5e4cf58958b5e0d7748925c75eb5ff (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
{config, ...}: {
  services.nginx = {
    enable = true;

    # enable recommended settings
    recommendedGzipSettings = true;
    recommendedOptimisation = true;
    recommendedTlsSettings = true;
    recommendedProxySettings = true;

    virtualHosts = {
      "auth.vhack.eu" = {
        forceSSL = true;
        enableACME = true;
        acmeRoot = null; # inherit from acme default setting
        locations = {
          "/" = {
            proxyPass = "http://localhost:${toString config.services.keycloak.settings.http-port}/";
          };
        };
      };
    };
  };

  services.postgresql.enable = true;

  services.keycloak = {
    enable = true;

    database = {
      type = "postgresql";
      createLocally = true;

      username = "keycloak";
      passwordFile = "/srv/keycloak/password";
    };

    settings = {
      hostname = "auth.vhack.eu";
      http-relative-path = "/";
      http-port = 38080;
      proxy = "passthrough";
      http-enabled = true;
    };
  };
}