1
0
Fork 0
puter/hosts/abacus/nginx.nix
2025-05-18 01:08:10 +02:00

33 lines
753 B
Nix

{ config, ... }:
{
services.nginx = {
enable = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
commonHttpConfig = ''
error_log stderr;
access_log /var/log/nginx/access.log;
'';
virtualHosts =
let
matchAll = ''~.*'';
matchWww = ''~^www\.(?<domain>.+)$'';
in
{
# Redirect anything that doesn't match any server name to networking.domain
${matchAll} = {
default = true;
rejectSSL = true;
globalRedirect = config.networking.domain;
};
# Redirect www to non-www
${matchWww}.globalRedirect = "$domain";
};
};
}