summaryrefslogtreecommitdiff
path: root/sys/web/sites/home.nix
blob: 616bf9427996f0fcb1f292ef789d502b6b794815 (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
30
31
32
33
34
35
{ config, lib, ... }:
with lib; let
  cfg = config.local.web.sites.home;
  inherit (config.local) domains;
in
{
  options.local.web.sites.home = {
    enable = mkEnableOption "home site";

    proxyUrl = mkOption {
      type = types.str;
    };
  };

  config = mkIf cfg.enable {
    local.web = {
      enable = mkDefault true;
      ownedCerts = [ "home" ];
    };

    services.nginx.virtualHosts.${domains.home.main} = {
      forceSSL = true;
      useACMEHost = domains.home.main;

      locations."/".extraConfig = ''
        proxy_pass ${cfg.proxyUrl};
        proxy_redirect http:// https://;

        # Necesario debido a websockets
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
      '';
    };
  };
}