chore(gluetun): Rework port forward

This commit is contained in:
Peter 2026-04-27 13:20:35 +02:00
parent bdeec6d819
commit 2b9630eb04
Signed by: Peter
SSH key fingerprint: SHA256:B5tYaxBExaDm74r1px9iVeZ6F/ZDiyiy9SbBqfZYrvg
2 changed files with 20 additions and 8 deletions

View file

@ -9,20 +9,26 @@ data:
VPN_TYPE: "wireguard" VPN_TYPE: "wireguard"
VPN_PORT_FORWARDING: on VPN_PORT_FORWARDING: on
VPN_PORT_FORWARDING_PROVIDER: protonvpn VPN_PORT_FORWARDING_PROVIDER: protonvpn
VPN_PORT_FORWARDING_UP_COMMAND: | VPN_PORT_FORWARDING_UP_COMMAND: "/scripts/port-up.sh"
/bin/sh -c ' VPN_PORT_FORWARDING_DOWN_COMMAND: "/scripts/port-down.sh"
FIREWALL_OUTBOUND_SUBNETS: 10.244.0.0/16,10.96.0.0/12
FIREWALL_INPUT_PORTS: "8112"
---
apiVersion: v1
kind: ConfigMap
metadata:
name: gluetun-scripts
data:
port-up.sh: |
#!/bin/sh
wget -O- --retry-connrefused \ wget -O- --retry-connrefused \
--post-data "json={\"listen_port\":{{PORTS}},\"current_network_interface\":\"tun0\",\"random_port\":false,\"upnp\":false}" \ --post-data "json={\"listen_port\":{{PORTS}},\"current_network_interface\":\"tun0\",\"random_port\":false,\"upnp\":false}" \
http://127.0.0.1:8112/api/v2/app/setPreferences 2>&1 http://127.0.0.1:8112/api/v2/app/setPreferences 2>&1
' port-down.sh: |
VPN_PORT_FORWARDING_DOWN_COMMAND: | #!/bin/sh
/bin/sh -c '
wget -O- --retry-connrefused \ wget -O- --retry-connrefused \
--post-data "json={\"listen_port\":0,\"current_network_interface\":\"lo\"}" \ --post-data "json={\"listen_port\":0,\"current_network_interface\":\"lo\"}" \
http://127.0.0.1:8112/api/v2/app/setPreferences 2>&1 http://127.0.0.1:8112/api/v2/app/setPreferences 2>&1
'
FIREWALL_OUTBOUND_SUBNETS: 10.244.0.0/16,10.96.0.0/12
FIREWALL_INPUT_PORTS: "8112"
--- ---
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap

View file

@ -33,6 +33,8 @@ spec:
- mountPath: "/gluetun/wireguard" - mountPath: "/gluetun/wireguard"
name: gluetun-wgconfig name: gluetun-wgconfig
readOnly: true readOnly: true
- name: gluetun-scripts
mountPath: /scripts
- name: gluetun-tmp - name: gluetun-tmp
mountPath: /tmp/gluetun mountPath: /tmp/gluetun
restartPolicy: Always restartPolicy: Always
@ -128,6 +130,10 @@ spec:
- name: gluetun-wgconfig - name: gluetun-wgconfig
secret: secret:
secretName: gluetun-wgconfig secretName: gluetun-wgconfig
- name: gluetun-scripts
configMap:
name: gluetun-scripts
defaultMode: 0755
- name: gluetun-tmp - name: gluetun-tmp
emptyDir: {} emptyDir: {}
- name: nfs-media - name: nfs-media