about summary refs log tree commit diff
path: root/nixos/tests/nginx-globalredirect.nix
blob: 5f5f4f344d8257eda215ceafe28acb4d2c23953a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import ./make-test-python.nix ({ pkgs, ... }: {
  name = "nginx-globalredirect";

  nodes = {
    webserver = { pkgs, lib, ... }: {
      services.nginx = {
        enable = true;
        virtualHosts.localhost = {
          globalRedirect = "other.example.com";
          # Add an exception
          locations."/noredirect".return = "200 'foo'";
        };
      };
    };
  };

  testScript = ''
    webserver.wait_for_unit("nginx")
    webserver.wait_for_open_port(80)

    webserver.succeed("curl --fail -si http://localhost/alf | grep '^Location:.*/alf'")
    webserver.fail("curl --fail -si http://localhost/noredirect | grep '^Location:'")
  '';
})