How to use a droplet to redirect incoming traffic to a specific public website?

Posted October 7, 2020 568 views

How do you configure a droplet thats full purpose is to exclusively take you to a specific website when (anyone) tries to enter the droplet’s IP/port into a web search? While also maintaining the IP of the droplet; so the website would see the droplet’s IP, not the user (therefore also Making it accessable to someone for which the website may be blocked in their country or by their firewall). Hope my question makes sense! :)

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.

Submit an Answer
1 answer

Hi there @7imontapia,

What you could do is install Nginx and create some redirect rules based on your requirements.

I would recommend going through this tutorial here on how to setup redirects with Nginx:

Hope that this helps!

by Mateusz Papiernik
HTTP redirection is a way to point one domain or address to another. There are a few different kinds of redirects (301 Moved Permanently and 302 Found), each of which mean something different to the client browser. You can add a redirect with `rewrite ^/$ redirect;` or `rewrite ^/$ permanent;` in your server configuration. This guide will cover a more in depth explanation of how to implement each kind of redirect in Nginx.
  • I’m not exactly sure what nginx is supposed to do. But, I went through the tutorials and all I’ve accomplished is that I can force a website search to go to my droplet server(on my local computer by changing the hosts file) and have it display some text. I might not be doing the redirecting thing properly, or maybe it’s just not what I need.
    I want to basically do the opposite of what i’ve accomplished with the nginx tutorials so far, which is typing in the droplet IP in a web search –> getting to the website(while on the droplet IP still) if that makes sense. Is using nginx the right way for me to be doing this? Am I just using it wrong (at the redirecting level maybe if anything). Or is it just not the right thing for what I’m trying to do?

  • Am I able to direct my droplet IP to a specific website using nginx? And how do I do that, if I can? because it’s not very clear

    • Hello,

      Do you want to redirect the IP address to a website hosted on your Droplet? Or to an external website?

      If you want to direct the IP to a specific website, have to first upload your website to your server in the /var/www/html directory. That way when visiting your IP it will be showing the content of your website.