summaryrefslogtreecommitdiff
path: root/os/srv/nginx.nix
blob: b0c01a7432eff042570d67e50ccf4878a9e4f04f (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
{ config, lib, ... }:

let
  cfg = config.os.srv.nginx;
in
{
  options.os.srv.nginx = {
    enable = lib.mkEnableOption "the NGINX reverse proxy service";

    openFirewall = lib.mkOption {
      type = lib.types.bool;
      default = true;
      description = "Whether to open ports 80 and 443 in the firewall.";
    };
  };

  config = lib.mkIf cfg.enable {
    services.nginx = {
      enable = true;

      recommendedProxySettings = true;
      recommendedTlsSettings = true;
      recommendedOptimisation = true;
      recommendedGzipSettings = true;
    };

    networking.firewall.allowedTCPPorts = lib.mkOptional cfg.openFirewall [
      80
      443
    ];

    systemd.tmpfiles.rules = [
      "d /var/log/nginx 0750 nginx adm -"
    ];
  };
}