summary refs log tree commit diff
path: root/nixos/modules/services
diff options
context:
space:
mode:
authorVincent Bernat <vincent@bernat.ch>2022-12-03 18:58:33 +0100
committerVincent Bernat <vincent@bernat.ch>2022-12-18 12:21:27 +0100
commitfc39b5ecc8bb862026facc1c96b176ffda7adaaa (patch)
tree036b06f36884be78d90341a3a0c68bc0341e0409 /nixos/modules/services
parent04f574a1c0fde90b51bf68198e2297ca4e7cccf4 (diff)
downloadnixpkgs-fc39b5ecc8bb862026facc1c96b176ffda7adaaa.tar
nixpkgs-fc39b5ecc8bb862026facc1c96b176ffda7adaaa.tar.gz
nixpkgs-fc39b5ecc8bb862026facc1c96b176ffda7adaaa.tar.bz2
nixpkgs-fc39b5ecc8bb862026facc1c96b176ffda7adaaa.tar.lz
nixpkgs-fc39b5ecc8bb862026facc1c96b176ffda7adaaa.tar.xz
nixpkgs-fc39b5ecc8bb862026facc1c96b176ffda7adaaa.tar.zst
nixpkgs-fc39b5ecc8bb862026facc1c96b176ffda7adaaa.zip
nginx: make global redirect vhost option accept exceptions
By moving the return into a location directive, one can provide
exceptions by adding locations. This is similar to what the forceSSL
option does.
Diffstat (limited to 'nixos/modules/services')
-rw-r--r--nixos/modules/services/web-servers/nginx/default.nix4
1 files changed, 3 insertions, 1 deletions
diff --git a/nixos/modules/services/web-servers/nginx/default.nix b/nixos/modules/services/web-servers/nginx/default.nix
index 85c76ed59d6..0b0e0de21df 100644
--- a/nixos/modules/services/web-servers/nginx/default.nix
+++ b/nixos/modules/services/web-servers/nginx/default.nix
@@ -318,7 +318,9 @@ let
           ${acmeLocation}
           ${optionalString (vhost.root != null) "root ${vhost.root};"}
           ${optionalString (vhost.globalRedirect != null) ''
-            return 301 http${optionalString hasSSL "s"}://${vhost.globalRedirect}$request_uri;
+            location / {
+              return 301 http${optionalString hasSSL "s"}://${vhost.globalRedirect}$request_uri;
+            }
           ''}
           ${optionalString hasSSL ''
             ssl_certificate ${vhost.sslCertificate};