From f8d69b1784b1fbbb6fe6abfa4a384fc8a75dbdef Mon Sep 17 00:00:00 2001 From: clerie Date: Sat, 26 Feb 2022 16:14:07 +0100 Subject: [PATCH] Add captive portal detection service --- hosts/web-2/configuration.nix | 1 + hosts/web-2/ping.nix | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 hosts/web-2/ping.nix diff --git a/hosts/web-2/configuration.nix b/hosts/web-2/configuration.nix index aa45eae..1de9910 100644 --- a/hosts/web-2/configuration.nix +++ b/hosts/web-2/configuration.nix @@ -12,6 +12,7 @@ ./ip.nix ./meow.nix ./milchinsel.nix + ./ping.nix ./prediger.nix ./public.nix ./radicale.nix diff --git a/hosts/web-2/ping.nix b/hosts/web-2/ping.nix new file mode 100644 index 0000000..1adc787 --- /dev/null +++ b/hosts/web-2/ping.nix @@ -0,0 +1,29 @@ +{ ... }: + +{ + services.nginx.virtualHosts = { + "ping.clerie.de" = { + enableACME = true; + addSSL = true; + locations."= /" = { + return = ''200 "This domain is used for connectivity checking and captive portal detection\n"''; + extraConfig = '' + types { } default_type "text/plain; charset=utf-8"; + ''; + }; + locations."/nm-check.txt" = { + return = ''200 "NetworkManager is online\n"''; + extraConfig = '' + types { } default_type "text_plain; charset=utf-8"; + add_header Cache-Control "max-age=0, must-revalidate"; + ''; + }; + locations."/" = { + return = ''404''; + }; + extraConfig = '' + access_log off; + ''; + }; + }; +}