Score:0

Is it possible to redirect a DNS to a different server in Apache?

cn flag

Let's say a DNS named system.example.com is redirected to my server IP where I have Apache installed in it. Let's also say the domain example.com was bought in GoDaddy and I have no admin control over this DNS, so that means I can't just redirect system.example.com to a different server in GoDaddy.

I'd like to create a new redirection with Apache to a server with a different IP address. In pseudocode, I think about something like:

<VirtualHost *:80>
    ServerName system.example.com
    Redirect 301 / http://192.0.2.1/
</VirtualHost>

This apache config doesn't work, it's just a sample. The idea is to redirect the domain that is arriving on my server to a different server. That would be exactly the same as using the A redirection in GoDaddy... But doing it in Apache instead. Is it possible? Can I redirect a DNS that is arriving on my server to a different server?

us flag
Rob
In your questions please refrain from using random domain names and use either your *own domain* or one of the [RFC 6761](https://tools.ietf.org/html/rfc6761#section-6.5) reserved domain names such as `example.com`, `example.org` or similar . Similarly you don't need to make up IP-addresses but when you don't want to use your own, use the special purpose [IPv4](https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml) or [IPv6](https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml) ranges.
Score:1
za flag

If I correctly understood what you are asking about, no. The name resolution is completely controlled on the client side, the only thing you can do is to update DNS RRs on the server. So ask somebody who can control DNS. We're solving business problems here, and this is normal to ask people to do actions for the business sake.

You can use raw IP address in HTTP addresses, so the redirection you suggested will work. However, this is not recommended nowadays to use IP addresses in this context. Better use any other domain that you can control. This is what you are essentially doing anyway.

Score:1
us flag
Rob

Yes and no.

No, you can't "redirect DNS" with a web server. If the hostname system.example.com needs to resolve to a different server then you need to adjust the DNS record. (You can't use the HTTP protocol to make changes at the level of the DNS protocol.)

Yes, you can configure your webserver so that HTTP requests (either all or only those for a particular hostname) are answered with a HTTP redirect.
A redirect instructs a web browser to make a new request to a different location and the visitor to your website will see that in the address bar of their browser http://system.example.com is changed to http://192.0.2.1/.

More common when you want a web server on system.example.com to show content from a different web server is by configuring it as "reverse proxy" rather than by sending a redirect. That leaves the address bar unchanged but may cause other issues and will cost you a lot more bandwidth.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.