1 import ./make-test-python.nix ({ pkgs, ...} :
4 backend = { pkgs, ... }: {
7 adminAddr = "foo@example.org";
8 virtualHosts.localhost.documentRoot = "${pkgs.valgrind.doc}/share/doc/valgrind/html";
10 networking.firewall.allowedTCPPorts = [ 80 ];
14 meta = with pkgs.lib.maintainers; {
19 proxy = { nodes, ... }: {
22 adminAddr = "bar@example.org";
23 extraModules = [ "proxy_balancer" "lbmethod_byrequests" ];
27 virtualHosts.localhost = {
29 <Location /server-status>
31 SetHandler server-status
34 <Proxy balancer://cluster>
36 BalancerMember http://${nodes.backend1.config.networking.hostName} retry=0
37 BalancerMember http://${nodes.backend2.config.networking.hostName} retry=0
41 ProxyPass /server-status !
42 ProxyPass / balancer://cluster/
43 ProxyPassReverse / balancer://cluster/
45 # For testing; don't want to wait forever for dead backend servers.
50 networking.firewall.allowedTCPPorts = [ 80 ];
56 client = { ... }: { };
62 proxy.wait_for_unit("httpd")
63 backend1.wait_for_unit("httpd")
64 backend2.wait_for_unit("httpd")
65 client.wait_for_unit("network.target")
67 # With the back-ends up, the proxy should work.
68 client.succeed("curl --fail http://proxy/")
70 client.succeed("curl --fail http://proxy/server-status")
72 # Block the first back-end.
75 # The proxy should still work.
76 client.succeed("curl --fail http://proxy/")
77 client.succeed("curl --fail http://proxy/")
79 # Block the second back-end.
82 # Now the proxy should fail as well.
83 client.fail("curl --fail http://proxy/")
85 # But if the second back-end comes back, the proxy should start
88 client.succeed("curl --fail http://proxy/")