Network and security journey in 2026 : Admin interfaces restricted by IP π and VPN Tunneling π
Following the attack explained here : https://dev.to/mino_rand/maintenance-security-journey-in-2026-post-mortem-measures-in-ghost-compromised-websites-43bp Some administration routes of the homelab were configured to us
Following the attack explained here : https://dev.to/mino_rand/maintenance-security-journey-in-2026-post-mortem-measures-in-ghost-compromised-websites-43bp
Some administration routes of the homelab were configured to use Traefik's ipAllowList middleware.β
But devices using mobile box internet in Madagascar doesn't have fixed IP adresses, so we needed to connect through a VPN and access these routes using the VPS public IP.
I got 403 Forbidden, even though the VPS public IP was already allowed.
Why?
When WireGuard accesses an external website, its traffic can leave through the VPS public IP.
However, when it accesses a website hosted on that same VPS, Docker can route the request back to Traefik through its bridge network.
The path was:
VPN client
|
v
wg-easy container
|
| Destination: VPS_PUBLIC_IP:443
v
Docker NAT
|
| Source becomes Docker gateway IP
v
Traefik
|
v
403 Forbidden
The VPN uses the VPS public IP as a destination, but Traefik receives the Docker gateway IP as the source.
And ipAllowList checks the source IP.
The solution
Instead of allowing the Docker gateway, the solution is to redirect VPN traffic to Traefik's container IP.
Traefik receives the VPN container's IP and can allow it.
VPN client
|
v
wg-easy container
|
| DNAT to Traefik:443
v
Traefik
|
| Source: VPN_CONTAINER_IP
v
IPAllowList β Website
This requires one WireGuard instance for all domains hosted behind the same Traefik.
1. Prepare the networkπ
First, use an existing Docker bridge network shared by Traefik and wg-easy. In this example, its name is web.
Reserve two IP addresses within that network:
TRAEFIK_CONTAINER_IPVPN_CONTAINER_IP
Check that neither address is already allocated.
Then, in the Traefik stack, assign its IP under the service definition:
services:
proxy:
networks:
web:
ipv4_address: TRAEFIK_CONTAINER_IP
docker-api: {}
networks:
web:
external: true
docker-api:
internal: true
Keep the rest of our Traefik configuration.
The ipv4_address property belongs under services.proxy.networks, not under the top-level networks section.
Updating Traefik can interrupt HTTPS connections during container recreation.
2. Deploy wg-easy π³
Next, we deploy wireguard though docker compose:
WireGuard VPN β Docker Compose (GitHub)
The file uses ghcr.io/wg-easy/wg-easy:15 and includes:
- WireGuard on UDP port
51820 - wg-easy administration on container port
51821, routed through Traefik - A Docker volume for WireGuard configuration
- An IPv4 address on the
webnetwork - Traefik HTTPS and
ipAllowListlabels
Before deployment, replace the placeholders:
| Placeholder | Replace with |
|---|---|
xxx |
VPN administration hostname |
xx.xx.xx.xx under ipv4_address
|
VPN_CONTAINER_IP |
xx.xx.xx.xx/32 under sourcerange
|
IP addresses allowed to manage wg-easy |
Then deploy the Compose file
Create a DNS A record pointing the VPN hostname to the VPS public IP.
Also allow inbound UDP/51820 in the VPS provider's firewall.
Do not publish port 51821 directly. Traefik already routes to it through Docker.
3. Configure WireGuard π οΈ
Open the wg-easy administration interface.
First, create the administrator account.
Then configure the WireGuard endpoint:
Host: VPN_HOSTNAME
Port: 51820
Create a client and import its QR code into the WireGuard application.
For a full IPv4 tunnel, use:
AllowedIPs = 0.0.0.0/0
Connect and verify Internet access.
At this point, the VPN works. But local websites may still return 403.
In fact, we need the NAT rule.
4. Add the DNAT hooks π οΈ
Open wg-easy β Admin Panel β Hooks.
Keep the existing forwarding and NAT rules.
Append the following rules to PostUp:
iptables -t nat -I PREROUTING 1 -i {{interface}} -d VPS_PUBLIC_IP/32 -p tcp --dport 443 -j DNAT --to-destination TRAEFIK_CONTAINER_IP;
iptables -t nat -I PREROUTING 1 -i {{interface}} -d VPS_PUBLIC_IP/32 -p udp --dport 443 -j DNAT --to-destination TRAEFIK_CONTAINER_IP;
Then append these rules to PostDown:
iptables -t nat -D PREROUTING -i {{interface}} -d VPS_PUBLIC_IP/32 -p tcp --dport 443 -j DNAT --to-destination TRAEFIK_CONTAINER_IP;
iptables -t nat -D PREROUTING -i {{interface}} -d VPS_PUBLIC_IP/32 -p udp --dport 443 -j DNAT --to-destination TRAEFIK_CONTAINER_IP;
Replace VPS_PUBLIC_IP and TRAEFIK_CONTAINER_IP with their IPv4 addresses.
Keep {{interface}} unchanged: wg-easy replaces it with the WireGuard interface name.
Why two protocols?
TCP/443 handles HTTPS. UDP/443 covers HTTP/3 when enabled in Traefik.
We can save the hooks and restart the WireGuard interface from wg-easy.
The rules now follow the interface lifecycle. No manual SSH command is required after a restart.
5. Update the website allowlists
Finally, add VPN_CONTAINER_IP/32 to the Traefik middleware protecting each administration route.
Example:
- "traefik.http.middlewares.wp-admin-ip.ipallowlist.sourcerange=ADMIN_PUBLIC_IP/32,VPN_CONTAINER_IP/32"
We keep the existing allowed IP addresses. π
Remove any temporary authorization for the Docker gateway IP.
π₯π₯π₯WARNINGπ₯π₯π₯ : Do not authorize the entire Docker subnet. The gateway may also represent traffic from other containers.
Each website keeps its domain, router, and middleware. Only the VPN container IP needs to be added.
6. Verification π§ͺ
Run these tests:
| Test | Expected result |
|---|---|
| VPN enabled β Internet | Works |
| VPN enabled β protected admin route | Access granted |
| VPN disabled β admin route from an unlisted IP | HTTP 403 |
| Existing allowed IP β admin route | Access granted |
This method applies to domains whose HTTPS traffic reaches the VPS public IP directly. Domains behind a CDN or another proxy require separate routing checks.
Conclusion
The VPS public IP was not the problem.
The problem was Docker's source NAT when a container accessed a published port on the same host.
The approach was:
Fix container IPs β Redirect VPN HTTPS traffic to Traefik β Allow the VPN container IP.
Now, multiple Docker stacks and domains can use one WireGuard deployment.
Adding a website requires one ipAllowList update. Adding an editor requires one WireGuard client.
The configuration lives in Docker Compose and wg-easy hooks, rather than undocumented commands on the VPS.
References
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.