From 0c16c81c2a7baedae2cb1122842c7aef2c4e0a39 Mon Sep 17 00:00:00 2001 From: RGBCube Date: Wed, 10 Jan 2024 11:15:48 +0300 Subject: [PATCH] Fix proxyPass directives and redirect www to root and any other tld that doesn't match anything to 404 --- flake.nix | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 2594a32..0173f42 100644 --- a/flake.nix +++ b/flake.nix @@ -153,7 +153,25 @@ enableACME = true; forceSSL = true; - proxyPass = "http://127.0.0.1:${cfg.port}"; + locations."/".proxyPass = "http://localhost:${cfg.port}"; + }; + + virtualHosts."www.${urlStripped}" = { + forceSSL = true; + enableACME = true; + + locations."/".extraConfig = '' + return 301 https://${urlStripped}$request_uri; + ''; + }; + + virtualHosts._ = { + forceSSL = true; + useACMEHost = urlStripped; + + locations."/".extraCofig = '' + proxy_pass http://localhost:${cfg.port}/404; + ''; }; };