{ config, lib, pkgs, ... }: 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; package = pkgs.nginx.override { openssl = pkgs.libressl; }; recommendedProxySettings = true; recommendedTlsSettings = true; recommendedOptimisation = true; recommendedGzipSettings = true; virtualHosts = { default = { serverName = "_"; default = true; rejectSSL = true; locations."/".return = "444"; }; }; }; security.acme = { acceptTerms = true; defaults.email = "adikro@disroot.org"; }; # users.users.nginx.extraGroups = [ "acme" ]; networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [ 80 443 ]; systemd.tmpfiles.rules = [ "d /var/log/nginx 0750 nginx adm -" ]; }; }