summaryrefslogtreecommitdiff
path: root/os/fscusat/modules/www.nix
blob: 24398da2157fd73d461bba4ae0ca822ff38fa753 (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
{ config, ... }:

let
  domain = "foss.fscusat.ac.in";
in
{
  networking.firewall.allowedTCPPorts = [ 80 443 ];

  sops.secrets = let 
    opts = {
      owner = config.services.nginx.user;
      group = config.services.nginx.group;
    };
  in{
    "cusat.ac.in/key" = opts;
    "cusat.ac.in/crt" = opts;
  };

  services.nginx = { 
    enable = true;
    recommendedTlsSettings = true;
    recommendedZstdSettings = true;
    recommendedOptimisation = true;
    recommendedGzipSettings = true;
    recommendedProxySettings = true;
    recommendedBrotliSettings = true;

    virtualHosts.${domain} = {
      forceSSL = true;
      sslCertificateKey = config.sops.secrets."cusat.ac.in/key".path;
      sslCertificate = config.sops.secrets."cusat.ac.in/crt".path;

      locations."/".extraConfig = "return 307 $scheme://$host/mirror/;";
    };
  };
}