2023-09-17 19:51:08 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
inputs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
2024-05-30 13:59:20 +00:00
|
|
|
name = "website_users";
|
|
|
|
cfg = config.services.skynet."${name}";
|
|
|
|
php_pool = name;
|
2023-09-17 19:51:08 +00:00
|
|
|
in {
|
2023-09-15 23:04:39 +00:00
|
|
|
imports = [
|
|
|
|
];
|
|
|
|
|
2024-05-30 13:59:20 +00:00
|
|
|
options.services.skynet."${name}" = {
|
2024-05-30 16:55:29 +00:00
|
|
|
enable = mkEnableOption "Skynet User Linux Server";
|
2023-09-15 23:04:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
2024-06-17 19:53:27 +00:00
|
|
|
# we havea more limited ports range on the skynet server
|
|
|
|
services.skynet.prometheus.ports = {
|
|
|
|
node = 9000;
|
|
|
|
};
|
2023-09-15 23:04:39 +00:00
|
|
|
|
|
|
|
# allow more than admins access
|
2024-05-30 13:59:20 +00:00
|
|
|
services.skynet.ldap_client = {
|
2023-09-15 23:04:39 +00:00
|
|
|
groups = [
|
|
|
|
"skynet-admins-linux"
|
|
|
|
"skynet-users-linux"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
# Website config
|
2024-05-30 12:34:59 +00:00
|
|
|
services.skynet.acme.domains = [
|
2023-09-17 19:51:08 +00:00
|
|
|
"users.skynet.ie"
|
2023-09-15 23:04:39 +00:00
|
|
|
"*.users.skynet.ie"
|
|
|
|
];
|
|
|
|
|
2024-05-30 12:25:52 +00:00
|
|
|
services.skynet.dns.records = [
|
2023-09-17 19:51:08 +00:00
|
|
|
{
|
|
|
|
record = "users";
|
|
|
|
r_type = "CNAME";
|
2024-05-30 16:55:29 +00:00
|
|
|
value = config.services.skynet.host.name;
|
2023-09-17 19:51:08 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
record = "*.users";
|
|
|
|
r_type = "CNAME";
|
2024-05-30 16:55:29 +00:00
|
|
|
value = config.services.skynet.host.name;
|
2023-09-17 19:51:08 +00:00
|
|
|
}
|
2023-09-15 23:04:39 +00:00
|
|
|
];
|
|
|
|
|
2024-02-28 09:10:57 +00:00
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
vim
|
|
|
|
php
|
|
|
|
];
|
2023-09-28 10:59:51 +00:00
|
|
|
|
2023-12-22 15:52:34 +00:00
|
|
|
networking = {
|
|
|
|
defaultGateway = {
|
|
|
|
address = lib.mkDefault "193.1.96.161";
|
|
|
|
interface = lib.mkDefault "eth1";
|
|
|
|
};
|
|
|
|
};
|
2023-09-15 23:04:39 +00:00
|
|
|
|
|
|
|
# normally services cannot read home dirs
|
2023-09-17 19:51:08 +00:00
|
|
|
systemd.services.nginx.serviceConfig.ProtectHome = "read-only";
|
2024-04-20 02:18:13 +00:00
|
|
|
systemd.services."phpfpm-${php_pool}".serviceConfig.ProtectHome = lib.mkForce "read-only";
|
|
|
|
|
|
|
|
services.phpfpm.pools.${php_pool} = {
|
|
|
|
user = config.services.nginx.user;
|
|
|
|
group = config.services.nginx.group;
|
|
|
|
settings = {
|
|
|
|
"listen.owner" = config.services.nginx.user;
|
|
|
|
"pm" = "dynamic";
|
|
|
|
"pm.max_children" = 32;
|
|
|
|
"pm.max_requests" = 500;
|
|
|
|
"pm.start_servers" = 2;
|
|
|
|
"pm.min_spare_servers" = 2;
|
|
|
|
"pm.max_spare_servers" = 5;
|
|
|
|
"php_admin_value[error_log]" = "stderr";
|
|
|
|
"php_admin_flag[log_errors]" = true;
|
|
|
|
"catch_workers_output" = true;
|
|
|
|
};
|
|
|
|
phpEnv."PATH" = lib.makeBinPath [pkgs.php];
|
|
|
|
};
|
2023-09-15 23:04:39 +00:00
|
|
|
|
|
|
|
services.nginx.virtualHosts = {
|
|
|
|
# main site
|
|
|
|
"*.users.skynet.ie" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "skynet";
|
|
|
|
serverName = "~^(?<user>.+)\.users\.skynet\.ie";
|
|
|
|
|
|
|
|
# username.users.skynet.ie/
|
|
|
|
# user goes:
|
|
|
|
# chmod 711 ~
|
|
|
|
# chmod -R 755 ~/public_html
|
|
|
|
|
2024-04-20 03:55:47 +00:00
|
|
|
locations = {
|
|
|
|
"/" = {
|
|
|
|
alias = "/home/$user/public_html/";
|
|
|
|
index = "index.html";
|
|
|
|
extraConfig = ''
|
|
|
|
autoindex on;
|
|
|
|
'';
|
|
|
|
tryFiles = "$uri$args $uri$args/ /index.html";
|
|
|
|
};
|
|
|
|
|
|
|
|
"~ ^(.+\\.php)(.*)$" = {
|
|
|
|
root = "/home/$user/public_html/";
|
|
|
|
index = "index.php";
|
|
|
|
extraConfig = ''
|
|
|
|
autoindex on;
|
|
|
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
|
|
|
fastcgi_pass unix:${config.services.phpfpm.pools.${php_pool}.socket};
|
|
|
|
include ${pkgs.nginx}/conf/fastcgi.conf;
|
|
|
|
'';
|
|
|
|
tryFiles = "$uri$args $uri$args/ /index.php";
|
|
|
|
};
|
2023-09-15 23:04:39 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-09-17 19:51:08 +00:00
|
|
|
}
|