How do i forward traffic on a droplet's IP/port to a specific website (that I dont own)

I just want to be able to go to the IP/port of my droplet in a web search, and it take me to a specific website(One that I do not own) So that if the destination website were blocked by a firewall/country I can still get to it through the droplet acting like a tunnel.

Can anyone tell me how I can do this? Any tutorials please

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi @7imontapia,

There are multiple ways to achieve this. You can use a WebService like Nginx and create a proxy. Another alternative would be to go for a NAT rule in your IPtables configurations.

Let’s try it out with a Nat rule as it won’t require you to install any new software on your droplet. Below will show you how to redirect port 3124 on one machine to port 3000 on a different machine / IP address. This can be useful for firewall related reasons.

Step 1 :

iptables -t nat -A PREROUTING -p tcp --dport 3124 -j DNAT --to-destination XXX.XXX.XXX.XXX:3000

This will route traffic incoming on port 3124 to XXX.XXX.XXX.XXX on port 3000. You can put in any port or IP address you need there to replace XXX.XXX.XXX.XXX.

Step 2 :

iptables -t nat -A POSTROUTING -j MASQUERADE

We set MASQUERADE to mask the IP address of the connecting system and use the gateway IP address instead. This is necessary for it to communicate back to the gateway, then to your client.

That’s all, you should be ready to go.

Regards, KFSys