From cbce4aa2289f492e792bdc66ce9fd79728a01b94 Mon Sep 17 00:00:00 2001 From: ashisgreat22 Date: Wed, 18 Mar 2026 03:19:31 +0100 Subject: [PATCH] feat(nginx): add extraLocations option for WebSocket support Co-Authored-By: Claude Opus 4.6 --- modules/nginx.nix | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/modules/nginx.nix b/modules/nginx.nix index 400528a..66fd91d 100644 --- a/modules/nginx.nix +++ b/modules/nginx.nix @@ -44,6 +44,23 @@ in default = ""; description = "Extra Nginx config for this location"; }; + extraLocations = lib.mkOption { + type = lib.types.attrsOf (lib.types.submodule { + options = { + proxyPass = lib.mkOption { + type = lib.types.str; + description = "Proxy target URL"; + }; + extraConfig = lib.mkOption { + type = lib.types.lines; + default = ""; + description = "Extra Nginx config for this location"; + }; + }; + }); + default = { }; + description = "Additional location blocks to add to this virtual host"; + }; }; }); default = { }; @@ -79,10 +96,18 @@ in enableACME = true; forceSSL = true; - locations."/" = { - proxyPass = "http://127.0.0.1:${toString opts.port}"; - extraConfig = opts.extraConfig; - }; + locations = { + "/" = { + proxyPass = "http://127.0.0.1:${toString opts.port}"; + extraConfig = opts.extraConfig; + }; + } // lib.mapAttrs' (locPath: locOpts: { + name = locPath; + value = { + proxyPass = locOpts.proxyPass; + extraConfig = locOpts.extraConfig; + }; + }) opts.extraLocations; }; }) cfg.domains; };