about summary refs log tree commit diff
path: root/modules
diff options
context:
space:
mode:
authorsefidel <contact@sefidel.net>2024-02-03 04:12:13 +0900
committersefidel <contact@sefidel.net>2024-02-03 04:12:13 +0900
commit327fd3d78658ffb03a4826668dc52e9b20b36b09 (patch)
tree08aaf735127084b18321b5179c25d155d18c092a /modules
parentea56024728e8ad502ddb3e05f7244fe57ca789e3 (diff)
downloadnixrc-327fd3d78658ffb03a4826668dc52e9b20b36b09.tar.gz
nixrc-327fd3d78658ffb03a4826668dc52e9b20b36b09.zip
feat(modules): add nginx
Diffstat (limited to 'modules')
-rw-r--r--modules/services/nginx.nix37
1 files changed, 37 insertions, 0 deletions
diff --git a/modules/services/nginx.nix b/modules/services/nginx.nix
new file mode 100644
index 0000000..f9a5a31
--- /dev/null
+++ b/modules/services/nginx.nix
@@ -0,0 +1,37 @@
+{ config, lib, ... }:
+
+with lib;
+let
+  cfg = config.modules.services.nginx;
+in
+{
+  options.modules.services.nginx = {
+    enable = mkEnableOption "nginx proxy";
+  };
+  config = mkIf cfg.enable {
+    modules.services.acme.enable = true;
+
+    services.nginx = {
+      enable = true;
+      # prevent 3~5s downtime on update
+      enableReload = true;
+
+      recommendedGzipSettings = true;
+      recommendedOptimisation = true;
+      recommendedProxySettings = true;
+      recommendedTlsSettings = true;
+
+      # catch-all for unknown hosts.
+      virtualHosts."_" = {
+        default = true;
+        rejectSSL = true;
+
+        extraConfig = ''
+          return 444;
+        '';
+      };
+    };
+
+    users.extraUsers.nginx.extraGroups = [ "acme" ];
+  };
+}