Vpn: Fix proxy access.

This commit is contained in:
Dmitry Voronin 2024-11-24 04:41:06 +03:00
parent 76f33841c8
commit 02006b1ff7
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k
23 changed files with 31 additions and 28 deletions

View file

@ -30,6 +30,10 @@ in {
default = "${config.container.storage}/vpn";
type = lib.types.str;
};
clients = lib.mkOption {
default = "10.1.1.0/24";
type = lib.types.str;
};
};
config = lib.mkIf cfg.enable {
@ -38,14 +42,14 @@ in {
];
# HACK: When using `networking.interfaces.*` it breaks. This works tho.
systemd.services.vpn-route = {
systemd.services.vpn-route = util.mkStaticSystemdService {
enable = true;
description = "Hack vpn routes on host";
after = [ "container@vpn.service" ];
wants = [ "container@vpn.service" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${pkgs.iproute2}/bin/ip route add 10.1.1.0/24 via ${cfg.address} dev ve-vpn";
ExecStart = "${pkgs.iproute2}/bin/ip route add ${cfg.clients} via ${cfg.address} dev ve-vpn";
Type = "oneshot";
};
};

View file

@ -15,7 +15,7 @@ in {
location / {
allow ${config.container.localAccess};
allow ${config.container.module.status.address};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;
return 301 rtsp://${address}:${toString port}/live/main;

View file

@ -15,7 +15,7 @@ in {
location / {
allow ${config.container.localAccess};
allow ${config.container.module.status.address};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;

View file

@ -15,7 +15,7 @@ in {
location / {
allow ${config.container.localAccess};
allow ${config.container.module.status.address};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;

View file

@ -15,7 +15,7 @@ in {
location ~ ^/(settings/admin|settings/users|settings/apps|login|api) {
allow ${config.container.localAccess};
allow ${config.container.module.status.address};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;
proxy_pass http://''$${name}$request_uri;

View file

@ -15,7 +15,7 @@ in {
location / {
allow ${config.container.localAccess};
allow ${config.container.module.status.address};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;
proxy_pass http://''$${name}$request_uri;

View file

@ -14,7 +14,7 @@ in {
location ~ ^/(admin|api|user) {
allow ${config.container.localAccess};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;
proxy_pass http://''$${name}$request_uri;

View file

@ -15,7 +15,7 @@ in {
location / {
allow ${config.container.localAccess};
allow ${config.container.module.status.address};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;
proxy_pass http://''$${name}$request_uri;

View file

@ -15,7 +15,7 @@ in {
location / {
allow ${config.container.localAccess};
allow ${config.container.module.status.address};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;

View file

@ -15,7 +15,7 @@ in {
location / {
allow ${config.container.localAccess};
allow ${config.container.module.status.address};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;
proxy_pass http://''$${name}$request_uri;

View file

@ -15,7 +15,7 @@ in {
location / {
# allow ${config.container.localAccess};
# allow ${config.container.module.status.address};
# allow ${config.container.module.vpn.address};
# allow ${config.container.module.vpn.clients};
# allow ${config.container.module.frkn.address};
# deny all;
add_header X-Forwarded-Proto https;

View file

@ -15,7 +15,7 @@ in {
location / {
allow ${config.container.localAccess};
allow ${config.container.module.status.address};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;
proxy_pass http://''$${name}$request_uri;

View file

@ -15,7 +15,7 @@ in {
location / {
allow ${config.container.localAccess};
allow ${config.container.module.status.address};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;
proxy_pass http://''$${name}$request_uri;

View file

@ -15,7 +15,7 @@ in {
location / {
allow ${config.container.localAccess};
allow ${config.container.module.status.address};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;

View file

@ -17,7 +17,7 @@ in {
location / {
allow ${config.container.localAccess};
allow ${config.container.module.status.address};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;
proxy_pass http://''$${name}$request_uri;

View file

@ -15,7 +15,7 @@ in {
location / {
allow ${config.container.localAccess};
allow ${config.container.module.status.address};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;
proxy_pass http://''$${name}$request_uri;

View file

@ -17,7 +17,7 @@ in {
location / {
allow ${config.container.localAccess};
allow ${config.container.module.status.address};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;
proxy_pass http://''$${name}$request_uri;

View file

@ -15,7 +15,7 @@ in {
location / {
allow ${config.container.localAccess};
allow ${config.container.module.status.address};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;
proxy_pass http://''$${name}$request_uri;

View file

@ -14,7 +14,7 @@ in {
location ~ ^/(dashboard|settings) {
allow ${config.container.localAccess};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;
proxy_pass http://''$${name}$request_uri;
@ -22,7 +22,7 @@ in {
location / {
allow ${config.container.localAccess};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;
proxy_pass http://''$${name}$request_uri;

View file

@ -15,7 +15,7 @@ in {
location / {
allow ${config.container.localAccess};
allow ${config.container.module.status.address};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;
proxy_pass http://''$${name}$request_uri;

View file

@ -15,7 +15,7 @@ in {
location / {
allow ${config.container.localAccess};
allow ${config.container.module.status.address};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;
proxy_pass http://''$${name}$request_uri;

View file

@ -15,7 +15,7 @@ in {
location / {
allow ${config.container.localAccess};
allow ${config.container.module.status.address};
allow ${config.container.module.vpn.address};
allow ${config.container.module.vpn.clients};
allow ${config.container.module.frkn.address};
deny all;

View file

@ -50,8 +50,7 @@ in {
iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -d 0/0 -o ${wan} -j MASQUERADE
# Full access from VPN clients.
# iptables -I INPUT -j ACCEPT -s ${cfg.vpn.address} -d ${internal}
iptables -I INPUT -j ACCEPT -s 10.1.1.0/24 -d ${internal}
iptables -I INPUT -j ACCEPT -s ${cfg.vpn.clients} -d ${internal}
iptables -I INPUT -j ACCEPT -s ${cfg.frkn.address} -d ${internal}
# Full access from Lan.
@ -89,13 +88,13 @@ in {
+ (mkForward external 54631 cfg.download.address 54631 udp)
# Git SSH connections.
# + (mkForward external cfg.git.portSsh cfg.git.address cfg.git.portSsh tcp)
+ (mkForward external cfg.git.portSsh cfg.git.address cfg.git.portSsh tcp)
+ (mkForward internal cfg.git.portSsh cfg.git.address cfg.git.portSsh tcp)
# Print serivce.
+ (mkForward internal cfg.print.port cfg.print.address cfg.print.port tcp);
# SSH access.
# SSH access from WAN.
# + (mkForward external 22143 config.container.host 22143 tcp)
};