Skip to content

Commit

Permalink
test: NAT
Browse files Browse the repository at this point in the history
  • Loading branch information
jz8132543 committed Mar 6, 2024
1 parent 89a576d commit 9af0b79
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions nixos/modules/base/environment/isNAT/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,20 @@ in
Whether to enable NAT mode.
'';
};
AltHTTPS = mkOption {
altHTTPS = mkOption {
type = types.int;
default = 8443;
description = ''
The port of https alt
'';
};
AltHTTP = mkOption {
altHTTP = mkOption {
type = types.int;
default = 8080;
description = ''
The port of http alt
'';
};
services.traefik.dynamicConfigOptions.type = mkForce types.attrset;
};
config = {
# services.traefik.dynamicConfigOptions.http.routers = attrsets.updateManyAttrsByPath [
Expand All @@ -45,16 +44,16 @@ in
table ip nat {
chain prerouting {
type nat hook prerouting priority 0; policy accept;
tcp dport ${config.environment.AltHTTP} redirect to 80
tcp dport ${config.environment.AltHTTPS} redirect to 443
tcp dport ${toString config.environment.altHTTP} redirect to 80
tcp dport ${toString config.environment.altHTTPS} redirect to 443
}
chain postrouting {
type nat hook postrouting priority 0; policy accept;
}
}
'';
networking.firewall.allowedTCPPorts = with config.environment; [AltHTTPS AltHTTP];
networking.firewall.allowedUDPPorts = with config.environment; [AltHTTPS];
networking.firewall.allowedTCPPorts = with config.environment; [altHTTPS altHTTP];
networking.firewall.allowedUDPPorts = with config.environment; [altHTTPS];
};
}

0 comments on commit 9af0b79

Please sign in to comment.