1

I have a domain example.com with DNS A record pointing to a public ip x.x.x.x.
I need to get all http and https requets from that server and forward that traffic to another public ip y.y.y.y.
Any ideas of how can I accomplish that?
I have been reading about Nginx redirect, but I dont know if it is the proper way and if it can be done.
PD. I have a DNS A record for www.example.com pointing to y.y.y.y, the problem is with example.com because I can not change the DNS record to point to the ip y.y.y.y because that interfered with mail service from the server with the x.x.x.x address.

  • I did as @esa-jokinen suggested. I used a redirect with Nginx to the subdomain www.example.com, install my ssl certificates and everything is working. – Rodrigo Ortiz Mar 20 '20 at 06:36

2 Answers2

0

You can use subdomains if you can access dns configuration:

www.example.com.    IN  A   y.y.y.y
mail.example.com.   IN  A   x.x.x.x

If not use nginx (or other tool) to redirect traffic.

lukascode
  • 46
  • 2
0

You wouldn't HTTP redirect to an IP address, but to a hostname, instead. As you already have www.example.com pointing to the correct IP address, that should be easy. This day and age I assume you are using TLS, so this example for Nginx redirects both http:// and https://example.com to the canonical subdomain address https://www.example.com.

server { 
    listen 80; 
    listen 443 ssl; 
    server_name example.com; 
    return 301 https://www.example.com$request_uri; 
}
Esa Jokinen
  • 43,252
  • 2
  • 75
  • 122
  • Thank you very much for your response. You catch exactly what I was asking and clear up my mind. Basically I did what you suggested and everything works like a charm. – Rodrigo Ortiz Mar 20 '20 at 06:27