Skip to content

Commit bdcb96a

Browse files
committed
Add fallback nginx vhost
1 parent 5d1789d commit bdcb96a

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

components/reverse-proxy.nix

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,23 @@ in {
221221
cfg.backends;
222222

223223
virtualHosts =
224-
lib.attrsets.mapAttrs (name: host: let
224+
{
225+
"_fallback" = {
226+
default = true;
227+
serverName = "_";
228+
229+
listenAddresses = lib.uniqueStrings (
230+
cfg.defaultListenAddresses
231+
++ lib.flatten (lib.map (host: host.listenAddresses) (lib.attrValues cfg.hosts))
232+
);
233+
234+
forceSSL = true;
235+
useACMEHost = "fallback";
236+
237+
locations."/".return = "301 https://krantz.dev";
238+
};
239+
}
240+
// lib.attrsets.mapAttrs (name: host: let
225241
forwardAuth = lib.lists.any (location: location.forwardAuth) (lib.attrsets.attrValues host.locations);
226242
in {
227243
forceSSL = true;
@@ -270,6 +286,16 @@ in {
270286
cfg.hosts;
271287
};
272288

273-
security.acme.certs = {};
289+
security.acme.certs.fallback = {
290+
profile = "shortlived";
291+
domain = "fallback";
292+
293+
webroot = "/var/lib/acme/acme-challenge";
294+
dnsProvider = null;
295+
296+
group = "nginx";
297+
reloadServices = ["nginx.service"];
298+
};
299+
systemd.services.acme-order-renew-fallback.enable = false;
274300
};
275301
}

0 commit comments

Comments
 (0)