I'm running a vps with Nginx Proxy Manager on it, and i was in the process of securing my server. I want to be able to connect to the port 81 of the server when i'm connceted via VPN but block it for everyone else on the internet.
I've tried to block port 80 on eth0 with ufw but with no results, after digging i found the DOCKER-USER filters for iptables.
So i've used:
iptables -I DOCKER-USER -i eth0 -p tcp --dport 81 -j DROP
It doesn't work very well. I can access port 81 from the public ip address of the server, one thing i've noticed the web panel becomes way slower.
What do i have to do to block port 81 of the container from being accessible from the public ip of the server?
EDIT: here are the rules i've tried:
DOCKER-USER -i eth0 -o eth0 -p tcp -m tcp --dport 81 -j DROP
DOCKER-USER -i eth0 -p tcp -m conntrack --ctdir ORIGINAL -m tcp --dport 81 -j DROP
MagiiTech's suggestion in the answer below:
# Allowing traffic to and from tun0:
iptables -I DOCKER-USER 1 -i tun0 -j ACCEPT
iptables -I DOCKER-USER 2 -o tun0 -j ACCEPT
# Now we block 81/tcp
iptables -I DOCKER-USER 3 ! -i lo -p tcp --dport 81 -j DROP
(this works but i cannot login to the webpanel via the vpn connection)