aboutsummaryrefslogtreecommitdiff
path: root/modules/containers/vaultwarden/default.nix
blob: 7fb4ae07955fc19ce496cbd4df7204a29d2b8fb5 (plain)
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
{ ... }:
let
  directory = "/opt/vaultwarden";
  domain = "steel-mountain.brownbread.net";
  port = "11001";
in
{
  systemd.tmpfiles.rules = builtins.map (x: "d ${x} 0755 share share - -") [ directory ];

  virtualisation.oci-containers.containers.vaultwarden = {
    image = "vaultwarden/server:latest";
    autoStart = true;
    ports = [ "${port}:80" ];
    volumes = [ "${directory}/data:/data" ];
    environment = {
      DOMAIN = domain;
      WEBSOCKET_ENABLED = "true";
      SIGNUPS_ALLOWED = "false";
      SHOW_PASSWORD_HINT = "false";
    };
  };

  services.caddy.virtualHosts.${domain}.extraConfig = ''
    encode zstd gzip
    reverse_proxy http://localhost:${port} {
      header_up X-Real-IP {remote_host}
    }
  '';
}