Forward Different External Ip Addresses to Different Localhost: Ports on a Local Machine

We are spinning a nodejs server that emulates a machine's API on Ubuntu Linux. The objective is to be able to connect to i.e. 10.0.0.5:4028 and this should connect to localhost:4020, 10.0.0.6:4028 should connect to localhost:4021, and so on...

Is there a way to map external IPs to localhost ports?

I have thought of nginx using nginx streams and changing the hosts file on ubuntu, but that doesn't sound like the most elegant and correct way to do this.

Any ideas?

Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article