blob: d6949227d3be72af2f50422526b9a61f8ac3cf39 (
plain)
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
|
{ ... }:
let
defaultNginxSocketPath = "/var/run/nginx/default-test.sock";
nginxSocketPath = "/var/run/nginx/test.sock";
in
{
name = "nginx-unix-socket";
nodes = {
webserver =
{ pkgs, lib, ... }:
{
services.nginx = {
enable = true;
defaultListen = [ { addr = "unix:${defaultNginxSocketPath}"; } ];
virtualHosts.defaultLocalhost = {
serverName = "defaultLocalhost";
locations."/default".return = "200 'bar'";
};
virtualHosts.localhost = {
serverName = "localhost";
listen = [ { addr = "unix:${nginxSocketPath}"; } ];
locations."/test".return = "200 'foo'";
};
};
};
};
testScript = ''
webserver.wait_for_unit("nginx")
webserver.wait_for_open_unix_socket("${defaultNginxSocketPath}", timeout=1)
webserver.wait_for_open_unix_socket("${nginxSocketPath}", timeout=1)
webserver.succeed("curl --fail --silent --unix-socket '${defaultNginxSocketPath}' http://defaultLocalhost/default | grep '^bar$'")
webserver.succeed("curl --fail --silent --unix-socket '${nginxSocketPath}' http://localhost/test | grep '^foo$'")
'';
}
|