1

I use the following route on my host machine in order to pass all my traffic to a NGINX server running at port 8080.

-A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

Unfortunately when I have that rule enabled all LXD containers (LXC for Ubuntu) cannot use:

apt-get update

since it resolves the repos as my domain.

Can I somehow prevent that?

1 Answer 1

1

You are redirecting all the tcp/80 traffic with your rule.
In order to redirect only the traffic you want, you have to specify an interface or an ip address. For example, you could use instead:

-A PREROUTING -i $MY_WAN_INTERFACE -p tcp --dport 80 -j REDIRECT --to-port 8080

Or, if you need to redirect some of your LAN traffic aswell, you could write:

-A PREROUTING -d $MY_PUBLIC_IP -p tcp --dport 80 -j REDIRECT --to-port 8080
-A PREROUTING -d $MY_PRIVATE_IP -p tcp --dport 80 -j REDIRECT --to-port 8080

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .