Report this

What is the reason for this report?

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

Posted on October 8, 2020

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



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!

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.

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.