infrastructure/machines/compute01/pages.nix
Julien Malka 53ee0a569b
All checks were successful
Check meta / check_dns (pull_request) Successful in 20s
Check meta / check_meta (pull_request) Successful in 20s
lint / check (push) Successful in 23s
build configuration / build_and_cache_geo01 (pull_request) Successful in 1m8s
build configuration / build_and_cache_storage01 (pull_request) Successful in 1m14s
build configuration / build_and_cache_rescue01 (pull_request) Successful in 1m17s
build configuration / build_and_cache_krz01 (pull_request) Successful in 2m8s
build configuration / build_and_cache_geo02 (pull_request) Successful in 1m4s
build configuration / build_and_cache_vault01 (pull_request) Successful in 1m20s
lint / check (pull_request) Successful in 24s
build configuration / build_and_cache_web01 (pull_request) Successful in 1m47s
build configuration / build_and_cache_web02 (pull_request) Successful in 1m18s
build configuration / build_and_cache_bridge01 (pull_request) Successful in 1m2s
build configuration / build_and_cache_compute01 (pull_request) Successful in 5m43s
feat(compute01): init pages server
2024-10-11 01:25:26 +02:00

90 lines
2 KiB
Nix

{
pkgs,
lib,
config,
...
}:
let
settings = {
ACME_ACCEPT_TERMS = "true";
ACME_EMAIL = "acme@dgnum.eu";
DNS_PROVIDER = "ovh";
OVH_ENDPOINT = "ovh-eu";
ENABLE_HTTP_SERVER = "false";
GITEA_ROOT = "https://git.dgnum.eu";
PORT = "8010";
PAGES_DOMAIN = "dgnum.page";
RAW_DOMAIN = "raw.dgnum.page";
};
# Necessary until upstream cuts a new release because of
# https://codeberg.org/Codeberg/pages-server/issues/235
# that is fixed on main
package = pkgs.callPackage ./codeberg-pages-custom.nix { };
in
{
age-secrets.autoMatch = [ "pages_env_file" ];
networking.firewall.allowedTCPPorts = [
80
443
];
systemd.services.codeberg-pages = {
description = "Codeberg pages server";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
environment = settings;
serviceConfig = {
Type = "simple";
StateDirectory = "codeberg-pages";
EnvironmentFile = config.age.secrets."pages_env_file".path;
WorkingDirectory = "/var/lib/codeberg-pages";
DynamicUser = true;
ExecStart = "${package}/bin/pages";
Restart = "on-failure";
ProtectHome = true;
ProtectSystem = "strict";
PrivateTmp = true;
PrivateDevices = true;
ProtectHostname = true;
ProtectClock = true;
ProtectKernelTunables = true;
ProtectKernelModules = true;
ProtectKernelLogs = true;
ProtectControlGroups = true;
NoNewPrivileges = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
RemoveIPC = true;
PrivateMounts = true;
};
};
services.nginx = {
enable = true;
streamConfig = ''
map $ssl_preread_server_name $sni_upstream {
hostnames;
default 0.0.0.0:8010;
${lib.concatStringsSep "\n" (
map (vhost: " ${vhost} 0.0.0.0 8443;") (lib.attrNames config.services.nginx.virtualHosts)
)}
}
server {
listen [::]:443;
ssl_preread on;
proxy_pass $sni_upstream;
}
'';
defaultSSLListenPort = 8443;
};
}