add frontend redirect hosts
This commit is contained in:
parent
2f8d666060
commit
4cdbebe7f9
2 changed files with 55 additions and 40 deletions
|
|
@ -120,6 +120,12 @@ in
|
|||
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 {
|
||||
type = lib.types.str;
|
||||
default = "https://${cfg.frontend.hostName}";
|
||||
|
|
@ -403,49 +409,55 @@ in
|
|||
recommendedProxySettings = lib.mkDefault true;
|
||||
recommendedTlsSettings = lib.mkDefault true;
|
||||
|
||||
virtualHosts = {
|
||||
${cfg.frontend.hostName} = lib.mkMerge [
|
||||
cfg.frontend.nginx
|
||||
{
|
||||
root = "${frontendPackage}";
|
||||
locations."/" = {
|
||||
tryFiles = "$uri $uri/ /index.html";
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
${cfg.backend.hostName} = lib.mkMerge [
|
||||
cfg.backend.nginx
|
||||
{
|
||||
root = "${appDir}/public";
|
||||
extraConfig = ''
|
||||
client_max_body_size ${uploadLimits.nginxClientMaxBodySize};
|
||||
'';
|
||||
locations = {
|
||||
"/" = {
|
||||
index = "index.php";
|
||||
tryFiles = "$uri $uri/ /index.php?$query_string";
|
||||
virtualHosts =
|
||||
lib.genAttrs cfg.frontend.redirectHostNames (redirectHostName: {
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
globalRedirect = cfg.frontend.hostName;
|
||||
})
|
||||
// {
|
||||
${cfg.frontend.hostName} = lib.mkMerge [
|
||||
cfg.frontend.nginx
|
||||
{
|
||||
root = "${frontendPackage}";
|
||||
locations."/" = {
|
||||
tryFiles = "$uri $uri/ /index.html";
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
"/storage/" = {
|
||||
alias = "${storagePath}/app/public/";
|
||||
extraConfig = ''
|
||||
expires 30d;
|
||||
access_log off;
|
||||
'';
|
||||
};
|
||||
${cfg.backend.hostName} = lib.mkMerge [
|
||||
cfg.backend.nginx
|
||||
{
|
||||
root = "${appDir}/public";
|
||||
extraConfig = ''
|
||||
client_max_body_size ${uploadLimits.nginxClientMaxBodySize};
|
||||
'';
|
||||
locations = {
|
||||
"/" = {
|
||||
index = "index.php";
|
||||
tryFiles = "$uri $uri/ /index.php?$query_string";
|
||||
};
|
||||
|
||||
"~ \\.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};
|
||||
'';
|
||||
"/storage/" = {
|
||||
alias = "${storagePath}/app/public/";
|
||||
extraConfig = ''
|
||||
expires 30d;
|
||||
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