fix: nginx and acme config

This commit is contained in:
Moritz Böhme 2025-05-14 15:25:46 +02:00
parent dad5fb17ec
commit 2c187cbe63
No known key found for this signature in database
GPG key ID: 970C6E89EB0547A9

View file

@ -1,4 +1,4 @@
{ {config, ...}: {
services.fail2ban = { services.fail2ban = {
enable = true; enable = true;
bantime-increment.enable = true; bantime-increment.enable = true;
@ -49,7 +49,7 @@
''; '';
}; };
networking.firewall.allowedTCPPorts = [80 443]; networking.firewall.allowedTCPPorts = [80 1443 443];
services.nginx = { services.nginx = {
enable = true; enable = true;
recommendedProxySettings = true; recommendedProxySettings = true;
@ -61,8 +61,20 @@
}; };
}; };
"moritz.foo" = { "moritz.foo" = {
forceSSL = true;
useACMEHost = "moritz.foo";
locations."/" = { locations."/" = {
return = "200 'Hello World!'"; return = "301 https://www.moritz.foo";
};
};
"www.moritz.foo" = {
forceSSL = true;
useACMEHost = "any.moritz.foo";
locations."/" = {
extraConfig = ''
add_header Content-Type text/html;
'';
return = "200 '<html><body>Hello World</body></html>'";
}; };
}; };
}; };
@ -76,18 +88,37 @@
} }
map $ssl_preread_server_name $name { map $ssl_preread_server_name $name {
*.moritz.foo self; hostnames;
moritz.foo self; .moritz.foo self;
*.moritzboeh.me diskstation; .moritzboeh.me diskstation;
moritzboeh.me diskstation;
default diskstation;
} }
server { server {
listen 443; listen 1443;
ssl_preread on; ssl_preread on;
proxy_pass $name; proxy_pass $name;
} }
''; '';
}; };
security.acme = {
acceptTerms = true;
defaults.email = "acme@moritzboeh.me";
defaults.dnsResolver = "1.1.1.1:53";
certs."moritz.foo" = {
dnsProvider = "cloudflare";
group = "nginx";
environmentFile = config.clan.core.vars.generators.acme.files.vars.path;
};
certs."any.moritz.foo" = {
domain = "*.moritz.foo";
dnsProvider = "cloudflare";
group = "nginx";
environmentFile = config.clan.core.vars.generators.acme.files.vars.path;
};
};
clan.core.vars.generators.acme.prompts.vars = {
persist = true;
type = "multiline";
};
} }