1{ ... }:
2{
3 name = "nginx-globalredirect";
4
5 nodes = {
6 webserver =
7 { pkgs, lib, ... }:
8 {
9 services.nginx = {
10 enable = true;
11 virtualHosts.localhost = {
12 globalRedirect = "other.example.com";
13 # Add an exception
14 locations."/noredirect".return = "200 'foo'";
15 };
16 };
17 };
18 };
19
20 testScript = ''
21 webserver.wait_for_unit("nginx")
22 webserver.wait_for_open_port(80)
23
24 webserver.succeed("curl --fail -si http://localhost/alf | grep '^Location:.*/alf'")
25 webserver.fail("curl --fail -si http://localhost/noredirect | grep '^Location:'")
26 '';
27}