2023-09-13 13:24:47 +00:00
|
|
|
import ./make-test-python.nix (
|
|
|
|
{ pkgs, lib, ... }:
|
|
|
|
{
|
|
|
|
name = "frp";
|
2024-04-27 12:37:51 +00:00
|
|
|
meta.maintainers = with lib.maintainers; [ zaldnoay ];
|
2023-09-13 13:24:47 +00:00
|
|
|
nodes = {
|
|
|
|
frps = {
|
|
|
|
networking = {
|
|
|
|
useNetworkd = true;
|
|
|
|
useDHCP = false;
|
|
|
|
firewall.enable = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.network.networks."01-eth1" = {
|
|
|
|
name = "eth1";
|
|
|
|
networkConfig.Address = "10.0.0.1/24";
|
2024-12-10 19:26:33 +00:00
|
|
|
};
|
2023-09-13 13:24:47 +00:00
|
|
|
|
|
|
|
services.frp = {
|
|
|
|
enable = true;
|
|
|
|
role = "server";
|
|
|
|
settings = {
|
2023-12-15 10:13:45 +00:00
|
|
|
bindPort = 7000;
|
|
|
|
vhostHTTPPort = 80;
|
2024-12-10 19:26:33 +00:00
|
|
|
};
|
|
|
|
};
|
2023-09-13 13:24:47 +00:00
|
|
|
};
|
|
|
|
|
2024-12-10 19:26:33 +00:00
|
|
|
frpc = {
|
2023-09-13 13:24:47 +00:00
|
|
|
networking = {
|
|
|
|
useNetworkd = true;
|
|
|
|
useDHCP = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.network.networks."01-eth1" = {
|
|
|
|
name = "eth1";
|
|
|
|
networkConfig.Address = "10.0.0.2/24";
|
|
|
|
};
|
|
|
|
|
|
|
|
services.httpd = {
|
|
|
|
enable = true;
|
2023-12-15 10:13:45 +00:00
|
|
|
adminAddr = "admin@example.com";
|
|
|
|
virtualHosts."test-appication" =
|
|
|
|
let
|
|
|
|
testdir = pkgs.writeTextDir "web/index.php" "<?php phpinfo();";
|
2024-12-10 19:26:33 +00:00
|
|
|
in
|
2023-12-15 10:13:45 +00:00
|
|
|
{
|
2023-09-13 13:24:47 +00:00
|
|
|
documentRoot = "${testdir}/web";
|
|
|
|
locations."/" = {
|
|
|
|
index = "index.php index.html";
|
2024-12-10 19:26:33 +00:00
|
|
|
};
|
|
|
|
};
|
2023-09-13 13:24:47 +00:00
|
|
|
phpPackage = pkgs.php81;
|
|
|
|
enablePHP = true;
|
2024-12-10 19:26:33 +00:00
|
|
|
};
|
|
|
|
|
2023-09-13 13:24:47 +00:00
|
|
|
services.frp = {
|
|
|
|
enable = true;
|
|
|
|
role = "client";
|
|
|
|
settings = {
|
2023-12-15 10:13:45 +00:00
|
|
|
serverAddr = "10.0.0.1";
|
|
|
|
serverPort = 7000;
|
2024-12-10 19:26:33 +00:00
|
|
|
proxies = [
|
|
|
|
{
|
2023-12-15 10:13:45 +00:00
|
|
|
name = "web";
|
|
|
|
type = "http";
|
|
|
|
localPort = 80;
|
|
|
|
customDomains = [ "10.0.0.1" ];
|
|
|
|
}
|
|
|
|
];
|
2024-12-10 19:26:33 +00:00
|
|
|
};
|
2023-09-13 13:24:47 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
|
|
|
start_all()
|
|
|
|
frps.wait_for_unit("frp.service")
|
|
|
|
frps.wait_for_open_port(80)
|
|
|
|
frpc.wait_for_unit("frp.service")
|
|
|
|
response = frpc.succeed("curl -fvvv -s http://127.0.0.1/")
|
|
|
|
assert "PHP Version ${pkgs.php81.version}" in response, "PHP version not detected"
|
|
|
|
response = frpc.succeed("curl -fvvv -s http://10.0.0.1/")
|
|
|
|
assert "PHP Version ${pkgs.php81.version}" in response, "PHP version not detected"
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
)
|