summaryrefslogtreecommitdiff
path: root/hosts/surtr/http/default.nix
blob: c70eb8f8b33f797829ef6a17efe2c6b3cf532a51 (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
{ 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 X448: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 2 2;
        proxy_temp_path /run/nginx-proxy-bodies 2 2;
      '';
      additionalModules = with pkgs.nginxModules; [ pam ];
      eventsConfig = ''
        worker_connections 2048;
      '';
    };
    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" "nginx-proxy-bodies" ];
        RuntimeDirectoryMode = "0750";
      };
    };

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