summaryrefslogtreecommitdiff
path: root/hosts/surtr/http/default.nix
blob: a77252ff1dc057c8d57635ea63eb40097623d77f (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{ config, lib, pkgs, ... }:
{
  imports = [
    ./webdav
  ];
  
  config = {
    services.nginx = {
      enable = true;
      # package = pkgs.nginxQuic;
      recommendedGzipSettings = true;
      recommendedProxySettings = true;
      recommendedTlsSettings = true;
      sslDhparam = config.security.dhparams.params.nginx.path;
      commonHttpConfig = ''
        ssl_ecdh_curve X25519:prime256v1:secp521r1:secp384r1;

        log_format main
                '$remote_addr "$remote_user" '
                '"$host" "$request" $status $bytes_sent '
                '"$http_referer" "$http_user_agent" '
                '$gzip_ratio';

        access_log syslog:server=unix:/dev/log main;
        error_log syslog:server=unix:/dev/log info;

        client_body_temp_path /run/nginx-client-bodies;
      '';
      additionalModules = with pkgs.nginxModules; [ dav pam ];
    };
    systemd.services.nginx = {
      preStart = lib.mkForce config.services.nginx.preStart;
      serviceConfig = {
        SupplementaryGroups = [ "shadow" ];
        ExecReload = lib.mkForce "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
        RuntimeDirectory = lib.mkForce [ "nginx" "nginx-client-bodies" ];
        RuntimeDirectoryMode = "0750";

        NoNewPrivileges = lib.mkForce false;
        PrivateDevices = lib.mkForce false;
        ProtectHostname = lib.mkForce false;
        ProtectKernelTunables = lib.mkForce false;
        ProtectKernelModules = lib.mkForce false;
        RestrictAddressFamilies = lib.mkForce [ ];
        LockPersonality = lib.mkForce false;
        MemoryDenyWriteExecute = lib.mkForce false;
        RestrictRealtime = lib.mkForce false;
        RestrictSUIDSGID = lib.mkForce false;
        SystemCallArchitectures = lib.mkForce "";
        ProtectClock = lib.mkForce false;
        ProtectKernelLogs = lib.mkForce false;
        RestrictNamespaces = lib.mkForce false;
        SystemCallFilter = lib.mkForce "";
        ReadWritePaths = [ "/srv/files" ];
      };
    };

    services.uwsgi = {
      enable = true;
      plugins = ["python3"];
      instance = {
        type = "emperor";
        vassals = {};
      };
    };
  };
}