infrastructure/machines/compute01/pages.nix
Julien Malka aaa3f0346a
All checks were successful
Check meta / check_meta (pull_request) Successful in 18s
Check meta / check_dns (pull_request) Successful in 20s
lint / check (push) Successful in 25s
build configuration / build_and_cache_storage01 (pull_request) Successful in 1m18s
build configuration / build_and_cache_geo02 (pull_request) Successful in 1m6s
build configuration / build_and_cache_geo01 (pull_request) Successful in 1m14s
build configuration / build_and_cache_rescue01 (pull_request) Successful in 1m18s
build configuration / build_and_cache_compute01 (pull_request) Successful in 1m40s
build configuration / build_and_cache_krz01 (pull_request) Successful in 2m4s
lint / check (pull_request) Successful in 25s
build configuration / build_and_cache_bridge01 (pull_request) Successful in 1m8s
build configuration / build_and_cache_vault01 (pull_request) Successful in 1m26s
build configuration / build_and_cache_web02 (pull_request) Successful in 1m13s
build configuration / build_and_cache_web01 (pull_request) Successful in 1m49s
feat(compute01): init pages server
2024-10-11 01:46:17 +02:00

82 lines
1.9 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
{
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 = {
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:8446;") (lib.attrNames config.services.nginx.virtualHosts)
)}
}
server {
listen [::]:443;
ssl_preread on;
proxy_pass $sni_upstream;
}
'';
defaultSSLListenPort = 8446;
};
}