depot/third_party/nixpkgs/nixos/tests/nghttpx.nix
Default email 3a4df29a92 Project import generated by Copybara.
GitOrigin-RevId: 3d7435c638baffaa826b85459df0fff47f12317d
2022-06-16 19:23:12 +02:00

61 lines
1.3 KiB
Nix

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")
'';
})