Compare commits
2 Commits
04d6a9b546
...
f3f5a9c726
| Author | SHA1 | Date | |
|---|---|---|---|
|
f3f5a9c726
|
|||
|
3d4aea8c5b
|
@@ -45,7 +45,8 @@ rec {
|
|||||||
|
|
||||||
https = {
|
https = {
|
||||||
certs = services_dir + "/http_certs";
|
certs = services_dir + "/http_certs";
|
||||||
domain = "gardling.com";
|
domain = "sigkill.computer";
|
||||||
|
old_domain = "gardling.com"; # Redirect traffic from old domain
|
||||||
};
|
};
|
||||||
|
|
||||||
gitea = {
|
gitea = {
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ let
|
|||||||
hugo --minify -d $out;
|
hugo --minify -d $out;
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
newDomain = service_configs.https.domain;
|
||||||
|
oldDomain = service_configs.https.old_domain;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
@@ -52,14 +55,53 @@ in
|
|||||||
services.caddy = {
|
services.caddy = {
|
||||||
enable = true;
|
enable = true;
|
||||||
email = "titaniumtown@proton.me";
|
email = "titaniumtown@proton.me";
|
||||||
|
|
||||||
|
# Enable on-demand TLS for old domain redirects
|
||||||
|
# Certs are issued dynamically when subdomains are accessed
|
||||||
|
globalConfig = ''
|
||||||
|
on_demand_tls {
|
||||||
|
ask http://localhost:9123/check
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
|
||||||
|
# Internal endpoint to validate on-demand TLS requests
|
||||||
|
# Only allows certs for *.${oldDomain}
|
||||||
|
extraConfig = ''
|
||||||
|
http://localhost:9123 {
|
||||||
|
@allowed expression {query.domain}.endsWith(".${oldDomain}") || {query.domain} == "${oldDomain}" || {query.domain} == "www.${oldDomain}"
|
||||||
|
respond @allowed 200
|
||||||
|
respond 403
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
|
||||||
virtualHosts = {
|
virtualHosts = {
|
||||||
${service_configs.https.domain} = {
|
${newDomain} = {
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
root * ${hugoWebsite}
|
root * ${hugoWebsite}
|
||||||
file_server browse
|
file_server browse
|
||||||
'';
|
'';
|
||||||
|
|
||||||
serverAliases = [ "www.${service_configs.https.domain}" ];
|
serverAliases = [ "www.${newDomain}" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Redirect old domain (bare + www) to new domain
|
||||||
|
${oldDomain} = {
|
||||||
|
extraConfig = ''
|
||||||
|
redir https://${newDomain}{uri} permanent
|
||||||
|
'';
|
||||||
|
serverAliases = [ "www.${oldDomain}" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Wildcard redirect for all old domain subdomains
|
||||||
|
# Uses on-demand TLS - certs issued automatically on first request
|
||||||
|
"*.${oldDomain}" = {
|
||||||
|
extraConfig = ''
|
||||||
|
tls {
|
||||||
|
on_demand
|
||||||
|
}
|
||||||
|
# {labels.2} extracts subdomain from *.gardling.com
|
||||||
|
redir https://{labels.2}.${newDomain}{uri} permanent
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user