how to redirect public ip to another public ip?
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 there,
To redirect a public IP to another public IP, you can use Nginx for example.
You can start by following the steps here on how to install Nginx:
https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04
Once Nginx is installed, you’ll need to configure it to perform the redirection:
/etc/nginx/sites-available
directory. You can create a new file here, such asredirect.conf
, with the following command:old_ip
with the public IP or domain you want to redirect from, andnew_ip
with the destination public IP or domain.This configuration listens for HTTP traffic on the old IP and redirects all requests to the new IP.
sites-enabled
directory:Now, any requests made to the old IP should be redirected to the new IP.
Essentially the old IP in this case, will be the IP address of your existing Droplet.
Feel free to share more information about the exact setup that you are trying to achieve and I will be happy to advise you further!
Best,
Bobby
You can use your Droplet’s Webserivce Apache/Nginx to do the redirect
1. Web Server Redirection (HTTP/S Level)
If you can set up a web server on the original server (where the current IP points to), you can configure it to redirect traffic to the new server. This only works for web traffic (HTTP/HTTPS), not for other protocols.
.htaccess
with a redirect rule.Here is an example for Nginx:
Replace
new-server-ip
with the IP address of your new server. Note that this method will not preserve the original IP in the address bar of a browser.Heya, @9cf6c12952c448868e20a91a0d8b77
As mentioned this can happen in your webserver of choice - Apache or Nginx.
Additionally if you’re using CloudFlare you can use the website redirect there. Have in mind that this works for a domain name and not with the droplet IP itself. I’m mentioning it as an additional option.
https://developers.cloudflare.com/rules/page-rules/how-to/url-forwarding/
Regards