feat(nginx): prevent other subdomains from being acccessed

This commit is contained in:
Mohammad Rafiq 2025-06-11 20:57:53 +08:00
parent 97746093ed
commit e4b260ada1
No known key found for this signature in database

View file

@ -1,6 +1,18 @@
{ config, lib, ... }:
let
cfg = config.server.web-servers;
proxyPasses = builtins.listToAttrs (
builtins.map (proxy: {
name = proxy.source;
value = {
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = proxy.target;
} // proxy.extraConfig;
};
}) cfg.nginx.proxies
);
in
{
options.server.web-servers = {
@ -45,18 +57,15 @@ in
];
services.nginx = {
enable = true;
virtualHosts = builtins.listToAttrs (
builtins.map (proxy: {
name = proxy.source;
value = {
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = proxy.target;
} // proxy.extraConfig;
virtualHosts = {
"_" = {
default = true;
rejectSSL = true;
locations."/" = {
return = "444";
};
}) cfg.nginx.proxies
);
};
} // proxyPasses;
};
})
];