notes: 2.3.0 -> 2.3.1 (#352950)
[NixPkgs.git] / nixos / tests / nghttpx.nix
blob11cac332827dc119e2a625ac58e478d3592502b8
1 let
2   nginxRoot = "/run/nginx";
3 in
4   import ./make-test-python.nix ({...}: {
5     name  = "nghttpx";
6     nodes = {
7       webserver = {
8         networking.firewall.allowedTCPPorts = [ 80 ];
9         systemd.services.nginx = {
10           preStart = ''
11             mkdir -p ${nginxRoot}
12             echo "Hello world!" > ${nginxRoot}/hello-world.txt
13           '';
14         };
16         services.nginx = {
17           enable = true;
18           virtualHosts.server = {
19             locations."/".root = nginxRoot;
20           };
21         };
22       };
24       proxy = {
25         networking.firewall.allowedTCPPorts = [ 80 ];
26         services.nghttpx = {
27           enable = true;
28           frontends = [
29             { server = {
30                 host = "*";
31                 port = 80;
32               };
34               params = {
35                 tls = "no-tls";
36               };
37             }
38           ];
39           backends = [
40             { server = {
41                 host = "webserver";
42                 port = 80;
43               };
44               patterns = [ "/" ];
45               params.proto = "http/1.1";
46             }
47           ];
48         };
49       };
51       client = {};
52     };
54     testScript = ''
55       start_all()
57       webserver.wait_for_open_port(80)
58       proxy.wait_for_open_port(80)
59       client.wait_until_succeeds("curl -s --fail http://proxy/hello-world.txt")
60     '';
61   })