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

25
web.nix
View file

@ -25,18 +25,33 @@
services.nginx = { services.nginx = {
enable = true; enable = true;
virtualHosts."default" = { recommendedTlsSettings = true;
default = true; recommendedProxySettings = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
virtualHosts."cordevelop.com" = {
serverAliases = [ "www.cordevelop.com" ];
enableACME = true;
forceSSL = true;
root = "/var/www/html"; root = "/var/www/html";
locations."/".index = "index.php index.html"; locations."/".index = "index.php index.html";
locations."~ \\.php$".extraConfig = '' locations."~ \\.php$".extraConfig = ''
fastcgi_pass unix:/run/phpfpm/www.sock; fastcgi_pass unix:/run/phpfpm/www.sock;
include ${pkgs.nginx}/conf/fastcgi_params; include ${pkgs.nginx}/conf/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 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) # database "app" and a MySQL user "web" that logs in via the local socket (no password)
services.mysql = { services.mysql = {
ensureDatabases = [ "app" ]; ensureDatabases = [ "app" ];
@ -46,5 +61,5 @@
}]; }];
}; };
networking.firewall.allowedTCPPorts = [ 80 ]; networking.firewall.allowedTCPPorts = [ 80 443 ];
} }