Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've got a DNS server running at "dns.u4ik.us" I have full control of the Apache server www.u4ik.us (same server as dns.uik.us) and the dns records themselves. I wanted to supply a service where people would type 96.245.253.143 into their example.com A record, and when someone accessed the site, would redirect to www.example.com (set to their actual IP). Essentially the same thing as WWWizer.com. Would I configure this in Apache or my DNS?

share|improve this question
    
+1 for the idea, I thought about this myself a few weeks ago but never got round to it. –  sam Jul 28 '11 at 13:51
    
@samarudge likewise - the real problem is getting yourself an IP that you can guarantee won't ever be revoked, since every single client of the service must (by definition) use the naked IP, and not a DNS name. –  Alnitak Jul 28 '11 at 15:00
    
@Alnitak Hmm hadn't thought about that. also could be a lot of traffic and no way to promote/monetize the service. Still it's one of those "It would make it easier, but I can't be bothered" kind of things =) –  sam Jul 28 '11 at 16:30
    
@samarudge yeah, tricky, especially when there's PCI compliance to sort out... ;-) –  Alnitak Jul 28 '11 at 17:44
    
cough Just going to leave this here and hope someone finds it useful apache-range-exploit.com –  Chris S Sep 8 '11 at 14:55
show 1 more comment

1 Answer

up vote 1 down vote accepted

This should be configured in Apache, set up a virtual host to listen on that IP (with no other VHosts listening) then use a rewrite rule to redirect.

Something along the lines of

<VirtualHost 96.245.253.143:80>
ServerName redirector
DocumentRoot /var/www/html/
<Location />
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301] 
</Location>
</VirtualHost>

(Note: Code not tested, guessing from memory but it should be something along those lines)

share|improve this answer
    
Thanks. What if, perhaps, I set up the thing to listen for "redirect.u4ik.us" port 80, where the user sets their site to go to CNAME redirect.u4ik.us instead of the A-name to my IP? Would I then be able to host a site there as well? –  U4iK_HaZe Jul 28 '11 at 14:06
    
I don't think you can use CNames on naked domains (Might be wrong). But you could host multiple sites on that IP so long as the redirector was the first virtual host defined (I.E. the default). VirtualHosts work on the host header sent by the browser, not the DNS records. –  sam Jul 28 '11 at 14:09
    
Yes, Apache will pick up the request for the domain, then look for the corresponding virtual host. I do think (not sure 100%) that you can set the CNAME as the root of a domain. As long as there are no A-records as the root. –  U4iK_HaZe Jul 28 '11 at 14:13
    
Okay, I think i got it. They will now enter the IP as their root A record. Unless my local cache is not up to date, It should be working. Thanks for your help. –  U4iK_HaZe Jul 28 '11 at 14:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.