Compare commits
3 commits
83632f5cf9
...
b1173f53bd
| Author | SHA1 | Date | |
|---|---|---|---|
| b1173f53bd | |||
| 4cdbebe7f9 | |||
| 2f8d666060 |
3 changed files with 75 additions and 41 deletions
|
|
@ -417,7 +417,10 @@ Example host configuration:
|
||||||
config.sops.secrets."borg-private-key".path;
|
config.sops.secrets."borg-private-key".path;
|
||||||
};
|
};
|
||||||
|
|
||||||
frontend.hostName = "rabbigerzi.com";
|
frontend = {
|
||||||
|
hostName = "rabbigerzi.com";
|
||||||
|
redirectHostNames = [ "www.rabbigerzi.com" ];
|
||||||
|
};
|
||||||
|
|
||||||
backend = {
|
backend = {
|
||||||
hostName = "api.rabbigerzi.com";
|
hostName = "api.rabbigerzi.com";
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,10 @@ let
|
||||||
borgPassphrase = "/run/secrets/borg-passphrase";
|
borgPassphrase = "/run/secrets/borg-passphrase";
|
||||||
borgPrivateKey = "/run/secrets/borg-private-key";
|
borgPrivateKey = "/run/secrets/borg-private-key";
|
||||||
};
|
};
|
||||||
frontend.hostName = "www.example.test";
|
frontend = {
|
||||||
|
hostName = "example.test";
|
||||||
|
redirectHostNames = [ "www.example.test" ];
|
||||||
|
};
|
||||||
backend = {
|
backend = {
|
||||||
hostName = "api.example.test";
|
hostName = "api.example.test";
|
||||||
environmentFile = "/run/secrets/rabbi-gerzi.env";
|
environmentFile = "/run/secrets/rabbi-gerzi.env";
|
||||||
|
|
@ -35,6 +38,10 @@ let
|
||||||
|
|
||||||
evaluatedHostName = evaluatedConfig.services.rabbi-gerzi.backend.hostName;
|
evaluatedHostName = evaluatedConfig.services.rabbi-gerzi.backend.hostName;
|
||||||
|
|
||||||
|
evaluatedFrontendHostName = evaluatedConfig.services.rabbi-gerzi.frontend.hostName;
|
||||||
|
|
||||||
|
frontendRedirectVirtualHost = evaluatedConfig.services.nginx.virtualHosts."www.example.test";
|
||||||
|
|
||||||
backendVirtualHost = evaluatedConfig.services.nginx.virtualHosts.${evaluatedHostName};
|
backendVirtualHost = evaluatedConfig.services.nginx.virtualHosts.${evaluatedHostName};
|
||||||
|
|
||||||
phpOptions = evaluatedConfig.services.phpfpm.pools.rabbi-gerzi.phpOptions;
|
phpOptions = evaluatedConfig.services.phpfpm.pools.rabbi-gerzi.phpOptions;
|
||||||
|
|
@ -66,6 +73,18 @@ let
|
||||||
passed = lib.hasInfix expectedNginxClientMaxBodySize backendVirtualHost.extraConfig;
|
passed = lib.hasInfix expectedNginxClientMaxBodySize backendVirtualHost.extraConfig;
|
||||||
message = "nginx client_max_body_size is not 6m";
|
message = "nginx client_max_body_size is not 6m";
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
passed = frontendRedirectVirtualHost.globalRedirect == evaluatedFrontendHostName;
|
||||||
|
message = "frontend redirect does not target the canonical host";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
passed = frontendRedirectVirtualHost.forceSSL;
|
||||||
|
message = "frontend redirect does not force HTTPS";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
passed = frontendRedirectVirtualHost.enableACME;
|
||||||
|
message = "frontend redirect does not enable ACME";
|
||||||
|
}
|
||||||
{
|
{
|
||||||
passed = backupConfig.repo == "ssh://mgjjruz9@mgjjruz9.repo.borgbase.com/./repo";
|
passed = backupConfig.repo == "ssh://mgjjruz9@mgjjruz9.repo.borgbase.com/./repo";
|
||||||
message = "Borg repository is not the Rabbi Gerzi repository";
|
message = "Borg repository is not the Rabbi Gerzi repository";
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,12 @@ in
|
||||||
description = "Frontend nginx virtual host name.";
|
description = "Frontend nginx virtual host name.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
redirectHostNames = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [ ];
|
||||||
|
description = "Frontend host names that redirect to the canonical host.";
|
||||||
|
};
|
||||||
|
|
||||||
publicUrl = lib.mkOption {
|
publicUrl = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = "https://${cfg.frontend.hostName}";
|
default = "https://${cfg.frontend.hostName}";
|
||||||
|
|
@ -403,49 +409,55 @@ in
|
||||||
recommendedProxySettings = lib.mkDefault true;
|
recommendedProxySettings = lib.mkDefault true;
|
||||||
recommendedTlsSettings = lib.mkDefault true;
|
recommendedTlsSettings = lib.mkDefault true;
|
||||||
|
|
||||||
virtualHosts = {
|
virtualHosts =
|
||||||
${cfg.frontend.hostName} = lib.mkMerge [
|
lib.genAttrs cfg.frontend.redirectHostNames (redirectHostName: {
|
||||||
cfg.frontend.nginx
|
enableACME = true;
|
||||||
{
|
forceSSL = true;
|
||||||
root = "${frontendPackage}";
|
globalRedirect = cfg.frontend.hostName;
|
||||||
locations."/" = {
|
})
|
||||||
tryFiles = "$uri $uri/ /index.html";
|
// {
|
||||||
};
|
${cfg.frontend.hostName} = lib.mkMerge [
|
||||||
}
|
cfg.frontend.nginx
|
||||||
];
|
{
|
||||||
|
root = "${frontendPackage}";
|
||||||
${cfg.backend.hostName} = lib.mkMerge [
|
locations."/" = {
|
||||||
cfg.backend.nginx
|
tryFiles = "$uri $uri/ /index.html";
|
||||||
{
|
|
||||||
root = "${appDir}/public";
|
|
||||||
extraConfig = ''
|
|
||||||
client_max_body_size ${uploadLimits.nginxClientMaxBodySize};
|
|
||||||
'';
|
|
||||||
locations = {
|
|
||||||
"/" = {
|
|
||||||
index = "index.php";
|
|
||||||
tryFiles = "$uri $uri/ /index.php?$query_string";
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
"/storage/" = {
|
${cfg.backend.hostName} = lib.mkMerge [
|
||||||
alias = "${storagePath}/app/public/";
|
cfg.backend.nginx
|
||||||
extraConfig = ''
|
{
|
||||||
expires 30d;
|
root = "${appDir}/public";
|
||||||
access_log off;
|
extraConfig = ''
|
||||||
'';
|
client_max_body_size ${uploadLimits.nginxClientMaxBodySize};
|
||||||
};
|
'';
|
||||||
|
locations = {
|
||||||
|
"/" = {
|
||||||
|
index = "index.php";
|
||||||
|
tryFiles = "$uri $uri/ /index.php?$query_string";
|
||||||
|
};
|
||||||
|
|
||||||
"~ \\.php$" = {
|
"/storage/" = {
|
||||||
extraConfig = ''
|
alias = "${storagePath}/app/public/";
|
||||||
include ${pkgs.nginx}/conf/fastcgi_params;
|
extraConfig = ''
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
expires 30d;
|
||||||
fastcgi_pass unix:${config.services.phpfpm.pools.${poolName}.socket};
|
access_log off;
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
"~ \\.php$" = {
|
||||||
|
extraConfig = ''
|
||||||
|
include ${pkgs.nginx}/conf/fastcgi_params;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
fastcgi_pass unix:${config.services.phpfpm.pools.${poolName}.socket};
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
}
|
];
|
||||||
];
|
};
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue