2024-03-16 03:32:07 +01:00
|
|
|
{ ... }: {
|
2023-12-21 07:52:18 +01:00
|
|
|
networking = {
|
2023-12-21 08:01:40 +01:00
|
|
|
firewall = {
|
2024-01-12 02:42:54 +01:00
|
|
|
enable = true;
|
2023-12-21 08:01:40 +01:00
|
|
|
allowedTCPPorts = [
|
|
|
|
80 # HTTP
|
|
|
|
443 # HTTPS
|
|
|
|
42420 # Vintage Story
|
|
|
|
25565 # Minecraft
|
2023-12-23 10:33:55 +01:00
|
|
|
1443 # Headscale DERP (tcp)
|
2024-03-11 06:38:32 +01:00
|
|
|
25 # Mailserver
|
|
|
|
143 # Mailserver
|
|
|
|
465 # Mailserver
|
|
|
|
587 # Mailserver
|
|
|
|
993 # Mailserver
|
|
|
|
4190 # Mailserver
|
|
|
|
4443 # Jitsi
|
2023-12-21 08:01:40 +01:00
|
|
|
];
|
2023-12-21 08:22:56 +01:00
|
|
|
allowedUDPPorts = [
|
2023-12-23 10:33:55 +01:00
|
|
|
3478 # Headscale DERP (udp)
|
2023-12-24 10:48:05 +01:00
|
|
|
10000 # Jitsi Meet (udp)
|
2024-03-30 15:53:56 +01:00
|
|
|
15636 # Enshrouded - Game
|
|
|
|
15637 # Enshrouded - Query Port
|
2023-12-21 08:22:56 +01:00
|
|
|
];
|
2024-01-12 02:41:26 +01:00
|
|
|
};
|
2023-12-21 08:01:40 +01:00
|
|
|
|
2023-12-21 07:52:18 +01:00
|
|
|
nftables = {
|
|
|
|
enable = true;
|
|
|
|
ruleset = ''
|
|
|
|
table ip nat {
|
|
|
|
chain PREROUTING {
|
2024-01-12 03:00:56 +01:00
|
|
|
type nat hook prerouting priority dstnat; policy accept;
|
2024-03-30 07:27:21 +01:00
|
|
|
iifname "enp0s4" udp dport 10000 dnat to 10.100.0.2:10000;
|
2024-03-30 15:53:56 +01:00
|
|
|
iifname "enp0s4" udp dport 15636 dnat to 10.100.1.2:15636;
|
|
|
|
iifname "enp0s4" udp dport 15637 dnat to 10.100.1.2:15637;
|
2023-12-21 07:52:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
2023-12-21 08:01:40 +01:00
|
|
|
|
2023-12-21 07:52:18 +01:00
|
|
|
nat = {
|
|
|
|
enable = true;
|
2023-12-21 08:21:40 +01:00
|
|
|
internalInterfaces = [ "enp0s4" ];
|
|
|
|
externalInterface = "wireguard0";
|
2023-12-21 07:52:18 +01:00
|
|
|
forwardPorts = [
|
2024-03-30 07:27:21 +01:00
|
|
|
{ sourcePort = 10000; proto = "udp"; destination = "10.100.0.2:10000"; }
|
2024-03-30 15:53:56 +01:00
|
|
|
{ sourcePort = 15636; proto = "udp"; destination = "10.100.1.2:15636"; }
|
|
|
|
{ sourcePort = 15637; proto = "udp"; destination = "10.100.1.2:15637"; }
|
2023-12-21 07:52:18 +01:00
|
|
|
];
|
|
|
|
};
|
2023-12-21 06:55:58 +01:00
|
|
|
};
|
2024-03-30 07:27:21 +01:00
|
|
|
|
2024-08-05 14:16:28 +02:00
|
|
|
|
2024-08-07 12:52:46 +02:00
|
|
|
# sops.secrets."cloudflare/api_key" = {
|
|
|
|
# owner = "haproxy";
|
|
|
|
# sopsFile = ../../../secrets/cloudflare.yaml;
|
|
|
|
# };
|
|
|
|
#
|
|
|
|
# sops.secrets."cloudflare/email" = {
|
|
|
|
# owner = "haproxy";
|
|
|
|
# sopsFile = ../../../secrets/cloudflare.yaml;
|
|
|
|
# };
|
2024-08-05 14:54:32 +02:00
|
|
|
|
2024-08-07 12:52:46 +02:00
|
|
|
# security.acme = {
|
|
|
|
# acceptTerms = true;
|
|
|
|
# defaults = {
|
|
|
|
# group = "haproxy";
|
|
|
|
# extraLegoFlags = [ "--pem" ];
|
|
|
|
# dnsPropagationCheck = false;
|
|
|
|
# email = "albert@sysctl.io";
|
|
|
|
# };
|
|
|
|
# certs."sysctl.io" = {
|
|
|
|
# directory = "/haproxy/";
|
|
|
|
# dnsProvider = "cloudflare";
|
|
|
|
# dnsResolver = "1.1.1.1:53";
|
|
|
|
# enableDebugLogs = true;
|
|
|
|
# credentialFiles = {
|
|
|
|
# "CF_DNS_API_TOKEN_FILE" = "/var/run/secrets/cloudflare/api_key";
|
|
|
|
# "CLOUDFLARE_EMAIL_FILE" = "/var/run/secrets/cloudflare/email";
|
|
|
|
# };
|
|
|
|
# domain = "sysctl.io";
|
|
|
|
# extraDomainNames = [ "*.sysctl.io" ];
|
|
|
|
# reloadServices = [ "haproxy" ];
|
|
|
|
# };
|
|
|
|
# };
|
2024-08-05 14:16:28 +02:00
|
|
|
|
2024-03-30 07:27:21 +01:00
|
|
|
services.haproxy = {
|
|
|
|
enable = true;
|
|
|
|
config = ''
|
2024-04-16 06:24:35 +02:00
|
|
|
defaults
|
|
|
|
timeout connect 10s
|
|
|
|
timeout client 30s
|
|
|
|
timeout server 30s
|
|
|
|
maxconn 3000
|
|
|
|
log global
|
|
|
|
|
2024-03-30 07:27:21 +01:00
|
|
|
frontend http
|
|
|
|
mode http
|
|
|
|
bind :80
|
2024-08-05 14:16:28 +02:00
|
|
|
option forwardfor
|
2024-03-30 07:27:21 +01:00
|
|
|
default_backend backend_http
|
2024-08-07 12:52:46 +02:00
|
|
|
backend backend_http
|
|
|
|
mode http
|
|
|
|
server framework-server 10.100.0.2
|
|
|
|
|
|
|
|
frontend https
|
|
|
|
mode tcp
|
|
|
|
bind :443
|
|
|
|
default_backend backend_tcp
|
|
|
|
|
2024-03-30 07:27:21 +01:00
|
|
|
frontend tcp
|
|
|
|
mode tcp
|
2024-08-07 12:52:46 +02:00
|
|
|
bind :42420
|
|
|
|
bind :25565
|
|
|
|
bind :4443
|
|
|
|
default_backend backend_tcp
|
|
|
|
backend backend_tcp
|
|
|
|
mode tcp
|
|
|
|
server framework-server 10.100.0.2
|
2024-04-17 11:07:07 +02:00
|
|
|
|
|
|
|
frontend mail
|
|
|
|
mode tcp
|
2024-03-30 07:27:21 +01:00
|
|
|
bind :25
|
|
|
|
bind :143
|
|
|
|
bind :465
|
|
|
|
bind :587
|
|
|
|
bind :993
|
|
|
|
bind :4190
|
2024-04-17 11:07:07 +02:00
|
|
|
default_backend backend_mail
|
|
|
|
backend backend_mail
|
|
|
|
mode tcp
|
2024-05-03 14:23:53 +02:00
|
|
|
server mailserver-wg 10.100.1.3
|
2024-03-30 07:27:21 +01:00
|
|
|
'';
|
|
|
|
};
|
2024-03-11 06:03:19 +01:00
|
|
|
}
|