feat(compute01): init pages server #151
|
@ -36,70 +36,80 @@ let
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
options.services.nginx.virtualHosts = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf (
|
||||||
Luj marked this conversation as resolved
Outdated
|
|||||||
|
lib.types.submodule {
|
||||||
|
config.extraConfig = ''
|
||||||
|
real_ip_header proxy_protocol;
|
||||||
|
set_real_ip_from 127.0.0.1;
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
);
|
||||||
Luj marked this conversation as resolved
Outdated
thubrecht
commented
`getExe package`
|
|||||||
|
};
|
||||||
|
|
||||||
systemd.services.codeberg-pages = {
|
config = {
|
||||||
inherit environment;
|
systemd.services.codeberg-pages = {
|
||||||
Luj marked this conversation as resolved
Outdated
thubrecht
commented
C'est strictement égal à C'est strictement égal à `lib.getExe package`
|
|||||||
description = "Codeberg pages server";
|
inherit environment;
|
||||||
after = [ "network.target" ];
|
description = "Codeberg pages server";
|
||||||
wantedBy = [ "multi-user.target" ];
|
after = [ "network.target" ];
|
||||||
serviceConfig = {
|
wantedBy = [ "multi-user.target" ];
|
||||||
Type = "simple";
|
serviceConfig = {
|
||||||
StateDirectory = "codeberg-pages";
|
Type = "simple";
|
||||||
EnvironmentFile = config.age.secrets."pages-environment_file".path;
|
StateDirectory = "codeberg-pages";
|
||||||
WorkingDirectory = "/var/lib/codeberg-pages";
|
EnvironmentFile = config.age.secrets."pages-environment_file".path;
|
||||||
DynamicUser = true;
|
WorkingDirectory = "/var/lib/codeberg-pages";
|
||||||
ExecStart = lib.getExe package;
|
DynamicUser = true;
|
||||||
Restart = "on-failure";
|
ExecStart = lib.getExe package;
|
||||||
ProtectHome = true;
|
Restart = "on-failure";
|
||||||
ProtectSystem = "strict";
|
ProtectHome = true;
|
||||||
PrivateTmp = true;
|
ProtectSystem = "strict";
|
||||||
PrivateDevices = true;
|
PrivateTmp = true;
|
||||||
ProtectHostname = true;
|
PrivateDevices = true;
|
||||||
ProtectClock = true;
|
ProtectHostname = true;
|
||||||
Luj marked this conversation as resolved
Outdated
thubrecht
commented
nginx est déja activé nginx est déja activé
|
|||||||
ProtectKernelTunables = true;
|
ProtectClock = true;
|
||||||
ProtectKernelModules = true;
|
ProtectKernelTunables = true;
|
||||||
ProtectKernelLogs = true;
|
ProtectKernelModules = true;
|
||||||
ProtectControlGroups = true;
|
ProtectKernelLogs = true;
|
||||||
NoNewPrivileges = true;
|
ProtectControlGroups = true;
|
||||||
Luj marked this conversation as resolved
Outdated
thubrecht
commented
`concatMapStringsSep` existe ( https://noogle.dev/f/lib/concatMapStringsSep )
|
|||||||
RestrictRealtime = true;
|
NoNewPrivileges = true;
|
||||||
Luj marked this conversation as resolved
Outdated
thubrecht
commented
`127.0.0.1` plutôt que `0.0.0.0` et il manque un `:` entre l'ip et le port
thubrecht
commented
Je comprends pas très bien à quoi sert ce hostnames d'ailleurs sachant que c'est pas défini ailleurs Je comprends pas très bien à quoi sert ce hostnames d'ailleurs sachant que c'est pas défini ailleurs
Luj
commented
Je pense que tu as raison Je pense que tu as raison
Luj
commented
le "hostnames" sert à pouvoir mettre des éléments du type *.dgnum.eu dans la map, effectivement plus utile ici le "hostnames" sert à pouvoir mettre des éléments du type *.dgnum.eu dans la map, effectivement plus utile ici
|
|||||||
RestrictSUIDSGID = true;
|
RestrictRealtime = true;
|
||||||
RemoveIPC = true;
|
RestrictSUIDSGID = true;
|
||||||
thubrecht
commented
L'alignement est décalé de deux caractères sur la gauche L'alignement est décalé de deux caractères sur la gauche
Luj
commented
C'est pour avoir l'indentation correcte sur le fichier de config (regarde les deux espaces au début de chaque ligne). C'est pour avoir l'indentation correcte sur le fichier de config (regarde les deux espaces au début de chaque ligne).
Comme tu préfères
thubrecht
commented
Ah, hmmm Ah, hmmm
Autre option, tu mets "\n " comme séparateur et pas les espaces dans la string du vhost
|
|||||||
PrivateMounts = true;
|
RemoveIPC = true;
|
||||||
|
PrivateMounts = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
services.nginx = {
|
||||||
|
defaultListen = [
|
||||||
|
{
|
||||||
|
addr = "127.0.0.1";
|
||||||
|
port = 8446;
|
||||||
|
ssl = true;
|
||||||
Luj marked this conversation as resolved
Outdated
thubrecht
commented
ligne vide en trop ? ligne vide en trop ?
|
|||||||
|
proxyProtocol = true;
|
||||||
|
}
|
||||||
Luj marked this conversation as resolved
Outdated
thubrecht
commented
idem idem
|
|||||||
|
{
|
||||||
|
addr = "0.0.0.0";
|
||||||
|
ssl = false;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
streamConfig = ''
|
||||||
|
map $ssl_preread_server_name $sni_upstream {
|
||||||
|
default 127.0.0.1:8010;
|
||||||
|
${
|
||||||
|
lib.concatMapStringsSep "\n " (vhost: "${vhost} 127.0.0.1:8446;") (
|
||||||
|
lib.attrNames config.services.nginx.virtualHosts
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 443;
|
||||||
|
ssl_preread on;
|
||||||
|
proxy_pass $sni_upstream;
|
||||||
|
proxy_protocol on;
|
||||||
|
}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.nginx = {
|
|
||||||
defaultListen = [
|
|
||||||
{
|
|
||||||
addr = "127.0.0.1";
|
|
||||||
port = 8446;
|
|
||||||
ssl = true;
|
|
||||||
proxyProtocol = true;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
addr = "0.0.0.0";
|
|
||||||
ssl = false;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
streamConfig = ''
|
|
||||||
map $ssl_preread_server_name $sni_upstream {
|
|
||||||
default 127.0.0.1:8010;
|
|
||||||
${
|
|
||||||
lib.concatMapStringsSep "\n " (vhost: "${vhost} 127.0.0.1:8446;") (
|
|
||||||
lib.attrNames config.services.nginx.virtualHosts
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen 443;
|
|
||||||
ssl_preread on;
|
|
||||||
proxy_pass $sni_upstream;
|
|
||||||
proxy_protocol on;
|
|
||||||
}
|
|
||||||
|
|
||||||
'';
|
|
||||||
defaultSSLListenPort = 8446;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Autant appeler directement la variable
environment
, comme ça tu peux faire un inherit et c'est plus clair dans le ``let ... in