summary refs log tree commit diff
path: root/hosts/vps/website.nix
blob: 5d767c50951c227d55a6b80a56499983d641b847 (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
36
37
38
39
40
41
42
43
44
45
{
  pkgs,
  config,
  lib,
  ...
}: {
  options.website.defaultHeaders = lib.mkOption {
    type = lib.types.str;
    default = ''
      header {
        -Server
        # disable indexing by search engines

        X-Robots-Tag "noindex, nofollow"
        # disable FLoC tracking
        Permissions-Policy interest-cohort=()

        # enable HSTS
        Strict-Transport-Security max-age=31536000;

        # disable clients from sniffing the media type
        X-Content-Type-Options nosniff

        # clickjacking protection
        X-Frame-Options DENY

        # keep referrer data off of HTTP connections
        Referrer-Policy no-referrer-when-downgrade
      }
    '';
  };
  config = {
    services.caddy = {
      enable = true;
      # virtualHosts = {
      #   "http://localhost".extraConfig = ''
      #     try_files ${pkgs.writeText "index.html" ''
      #       hello world
      #     ''} /
      #   '';
      # };
    };
    networking.firewall.allowedTCPPorts = [80 443];
  };
}