about summary refs log tree commit diff
path: root/nixos/tests/nghttpx.nix
blob: 11cac332827dc119e2a625ac58e478d3592502b8 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
let
  nginxRoot = "/run/nginx";
in
  import ./make-test-python.nix ({...}: {
    name  = "nghttpx";
    nodes = {
      webserver = {
        networking.firewall.allowedTCPPorts = [ 80 ];
        systemd.services.nginx = {
          preStart = ''
            mkdir -p ${nginxRoot}
            echo "Hello world!" > ${nginxRoot}/hello-world.txt
          '';
        };

        services.nginx = {
          enable = true;
          virtualHosts.server = {
            locations."/".root = nginxRoot;
          };
        };
      };

      proxy = {
        networking.firewall.allowedTCPPorts = [ 80 ];
        services.nghttpx = {
          enable = true;
          frontends = [
            { server = {
                host = "*";
                port = 80;
              };

              params = {
                tls = "no-tls";
              };
            }
          ];
          backends = [
            { server = {
                host = "webserver";
                port = 80;
              };
              patterns = [ "/" ];
              params.proto = "http/1.1";
            }
          ];
        };
      };

      client = {};
    };

    testScript = ''
      start_all()

      webserver.wait_for_open_port(80)
      proxy.wait_for_open_port(80)
      client.wait_until_succeeds("curl -s --fail http://proxy/hello-world.txt")
    '';
  })