2017-11-16 19:21:02 +01:00
|
|
|
let
|
2018-12-19 22:55:00 +01:00
|
|
|
nginxRoot = "/run/nginx";
|
2017-11-16 19:21:02 +01:00
|
|
|
in
|
2019-12-15 19:36:44 +01:00
|
|
|
import ./make-test-python.nix ({...}: {
|
2017-11-16 19:21:02 +01:00
|
|
|
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;
|
2019-08-13 23:52:01 +02:00
|
|
|
virtualHosts.server = {
|
2017-11-16 19:21:02 +01:00
|
|
|
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 = ''
|
2019-12-15 19:36:44 +01:00
|
|
|
start_all()
|
2017-11-16 19:21:02 +01:00
|
|
|
|
2022-06-11 14:22:53 +02:00
|
|
|
webserver.wait_for_open_port(80)
|
|
|
|
proxy.wait_for_open_port(80)
|
2019-12-15 19:36:44 +01:00
|
|
|
client.wait_until_succeeds("curl -s --fail http://proxy/hello-world.txt")
|
2017-11-16 19:21:02 +01:00
|
|
|
'';
|
|
|
|
})
|