From d803f78e7c97efa63eedf21229ca3adf51b6fd2f Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 28 Jul 2023 17:11:07 +0200 Subject: nixos/nginx: move status page config to `services.nginx` --- .../modules/services/web-servers/nginx/default.nix | 32 ++++++++++------------ 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'nixos/modules/services/web-servers') diff --git a/nixos/modules/services/web-servers/nginx/default.nix b/nixos/modules/services/web-servers/nginx/default.nix index e87159ba99c..427c6b300e1 100644 --- a/nixos/modules/services/web-servers/nginx/default.nix +++ b/nixos/modules/services/web-servers/nginx/default.nix @@ -261,23 +261,6 @@ let ${proxyCachePathConfig} - ${optionalString cfg.statusPage '' - server { - listen ${toString cfg.defaultHTTPListenPort}; - ${optionalString enableIPv6 "listen [::]:${toString cfg.defaultHTTPListenPort};" } - - server_name localhost; - - location /nginx_status { - stub_status on; - access_log off; - allow 127.0.0.1; - ${optionalString enableIPv6 "allow ::1;"} - deny all; - } - } - ''} - ${vhosts} ${cfg.appendHttpConfig} @@ -1175,6 +1158,21 @@ in services.nginx.additionalModules = optional cfg.recommendedBrotliSettings pkgs.nginxModules.brotli ++ lib.optional cfg.recommendedZstdSettings pkgs.nginxModules.zstd; + services.nginx.virtualHosts.localhost = mkIf cfg.statusPage { + listenAddresses = lib.mkDefault ([ + "0.0.0.0" + ] ++ lib.optional enableIPv6 "[::]"); + locations."/nginx_status" = { + extraConfig = '' + stub_status on; + access_log off; + allow 127.0.0.1; + ${optionalString enableIPv6 "allow ::1;"} + deny all; + ''; + }; + }; + systemd.services.nginx = { description = "Nginx Web Server"; wantedBy = [ "multi-user.target" ]; -- cgit 1.4.1