← Back to PureKit

Two Services, One Pair of Ports (80/443): Zero-Touch Split via iptables DNAT

#iptables#DNAT#Linux Networking#Zero Touch
Two Services, One Pair of Ports (80/443): Zero-Touch Split via iptables DNAT

The Conflict

A production deployment needed its object storage gateway to serve traffic on standard ports 80/443, while the cluster management UI already bound 80/443 on the same hosts.

Modifying the management platform’s listen ports carried 6 concrete operational risks—including broken internal health checks, upgrade overwrites, and reverse-proxy config drift.

Zero-Touch Network Solution

Because business traffic and management traffic lived on two distinct subnets / destination IPs, we solved the collision cleanly in the Linux kernel using iptables PREROUTING DNAT:

iptables -t nat -A PREROUTING -d <BUSINESS_IP> -p tcp --dport 80  -j DNAT --to-destination <BUSINESS_IP>:8080
iptables -t nat -A PREROUTING -d <BUSINESS_IP> -p tcp --dport 443 -j DNAT --to-destination <BUSINESS_IP>:8443

Both applications stayed 100% untouched, future upgrades never overwrite the routing rule, and rollback is a single command.

Enjoyed this note or seen a similar bug?

Feel free to drop a line—always glad to exchange ideas with fellow engineers.

Say hi · hi@purekit.net