use lets encrypt certificates and www.* support + fallback vhost

This commit is contained in:
freek 2026-10-09 10:05:08 +02:00
parent c4551c8fed
commit 0aee3fb1fd

21
web.nix
View file

@ -25,8 +25,15 @@
services.nginx = {
enable = true;
virtualHosts."default" = {
default = true;
recommendedTlsSettings = true;
recommendedProxySettings = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
virtualHosts."cordevelop.com" = {
serverAliases = [ "www.cordevelop.com" ];
enableACME = true;
forceSSL = true;
root = "/var/www/html";
locations."/".index = "index.php index.html";
locations."~ \\.php$".extraConfig = ''
@ -35,7 +42,15 @@
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
'';
};
# Anything else (bare IP, unknown names) gets no content and no certificate
virtualHosts."_" = {
default = true;
rejectSSL = true;
locations."/".return = "444";
};
};
# database "app" and a MySQL user "web" that logs in via the local socket (no password)
services.mysql = {
@ -46,5 +61,5 @@
}];
};
networking.firewall.allowedTCPPorts = [ 80 ];
networking.firewall.allowedTCPPorts = [ 80 443 ];
}