Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Host exposed Ports not container ports #108

Open
domx4q opened this issue Sep 1, 2023 · 1 comment
Open

Allow Host exposed Ports not container ports #108

domx4q opened this issue Sep 1, 2023 · 1 comment

Comments

@domx4q
Copy link

domx4q commented Sep 1, 2023

Hello,

Is there a way to allow the exposed ports insteed of the container ports? I know, I could just allow the specific port on a specific IP. But I have multiple containers with the same port inside and I need to expose them, but then there is overlapping.
I've added a rule to allow every container port on the tailscale network, because this is a private and secure network, so I can easily access every service. But on the public network, I only want to allow some ports. (The tailscale network behaves like a normal netweork interface, so it can be easily seperated.
The Problem is the overlapping of some ports, which are differently exposed, but same on the container.

@vodasams57
Copy link

vodasams57 commented Jan 11, 2024

From a user perspective, I totally agree.

Unfortunately, this is difficult. Docker applies NAT PREROUTING rules first, whereby the destination port in the IP frame is changed. The ufw-docker rules are applied in the FORWARD chain, namely DOCKER-USER. At this of time the ports already have been altered and the original port is not available anymore.

One option might be to use conntrack's feature "--ctorigdstport", because the conntrack table allows a stateful firewall.

In general: if you are aiming for a proper solution, put a dedicated firewall before the server. Separating the docker server and the firewall makes sense from a security perspective.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants