2025-05-18 01:08:10 +02:00
|
|
|
{ config, ... }:
|
2025-05-11 22:49:04 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2025-05-18 01:08:10 +02:00
|
|
|
globalRedirect = config.networking.domain;
|
2025-05-11 22:49:04 +02:00
|
|
|
};
|
|
|
|
# Redirect www to non-www
|
|
|
|
${matchWww}.globalRedirect = "$domain";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|