feat: added catch all route to reverse proxy that blocks connections on non specified hosts
This commit is contained in:
parent
81a6588537
commit
bb5c94ec2c
1 changed files with 19 additions and 1 deletions
|
|
@ -6,6 +6,11 @@
|
||||||
options.services.reverseProxy = {
|
options.services.reverseProxy = {
|
||||||
enable = lib.mkEnableOption "turn on the reverse proxy";
|
enable = lib.mkEnableOption "turn on the reverse proxy";
|
||||||
openFirewall = lib.mkEnableOption "open the firewall";
|
openFirewall = lib.mkEnableOption "open the firewall";
|
||||||
|
refuseUnmatchedDomains = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
description = "refuse connections for domains that don't match any configured virtual hosts";
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
ports = {
|
ports = {
|
||||||
http = lib.mkOption {
|
http = lib.mkOption {
|
||||||
type = lib.types.port;
|
type = lib.types.port;
|
||||||
|
|
@ -96,7 +101,20 @@
|
||||||
services.nginx = {
|
services.nginx = {
|
||||||
enable = true;
|
enable = true;
|
||||||
virtualHosts = lib.mkMerge (
|
virtualHosts = lib.mkMerge (
|
||||||
lib.lists.flatten (
|
(lib.optionals config.services.reverseProxy.refuseUnmatchedDomains [
|
||||||
|
{
|
||||||
|
"_" = {
|
||||||
|
default = true;
|
||||||
|
serverName = "_";
|
||||||
|
locations."/" = {
|
||||||
|
extraConfig = ''
|
||||||
|
return 444;
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
])
|
||||||
|
++ lib.lists.flatten (
|
||||||
lib.attrsets.mapAttrsToList (
|
lib.attrsets.mapAttrsToList (
|
||||||
name: service: let
|
name: service: let
|
||||||
hostConfig = {
|
hostConfig = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue