VirtualHost configuration

A client has a unique scenario where there exists an old domain name which must have an old DNS entry which just happens to point to the IP address of my clients load balancer. So anytime someone goes to abc.com, they see my clients content. The problem is that Google also sees the content on ABC.com and then things that my clients real domain name is just a copy of abc.com so it gives their real domain less weight in search results.

I originally solved this by adding a default VirtualHost entry that just 404’d any request that didn’t match an existing vhost, but that later came back to bite me as I could no longer browse the servers by IP address alone (necessary on occasion to check server health or replication issues). How can I go about defining my virtual hosts to handle this? Here is what I’m after:

Yes, it’s another registrar that’s pointing to us. And yes, it’s now a dedicated IP address for my client. I managed to track down the technical contact for one of the domains, but he hasn’t responded to emails or phone calls.

We run our own web servers and have Apache running now. We use virtual host configs to control the various test, development and production environments that all run off of the same server. The problem with using a default host to catch all unknown hosts is that it also catches NO host, as in using the IP address only to connect. See my original post for why that is necessary.

Chris,

Is that a registrar that’s pointing to your IP address?

Is that a dedicated IP address?

In either case, YOUR (local) DNS should not be configured to point that domain (that’s not yours) at your account. Shared IP addresses are common and are easily handled by Apache VirtualHost configurations (cPanel normally handles those as Addon Domains and modifies the VirtualHost configuration file AND local DNS modifications for you).

If all this fails, all you need to do is include some mod_rewrite code in your DocumentRoot:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\\.)?[I]offending.domain[/I]$ [NC]
RewriteRule .? - F

which will FAIL any request for the offending domain, www’d or not. Of course, this assumes that you have mod_rewrite enabled on your server and are allowed to post to the .htaccess file in your DocumentRoot (if not, get a good host).

Regards,

DK

Chris,

If you only have a problem with this one host (I can’t imaging a domain owner would want to misdirect their domain name), add that host as a VirtualHost then post some kind of message that the domain does NOT exist on your server. That seems about all you can do - unless contacting the domain’s registrar and demanding that they repoint to their own “parked” domain DNS.

Regards,

DK

That’s the problem - A DNS lookup on the impostor site does indeed show that it resolves to the same IP address that is used by my client. The DNS records themselves are hosted at another host altogether. That’s why i want to block any host that isn’t explicitly defined, just in case it were to happen again in the future (or we find another domain name from the same company as ABC.com - we already know of two)

Chris,

Okay, weird problem. However, from your description, I’d say that you know better than to attack this problem in your server’s httpd.

Personally, I’d make sure that my DNS did not accept the old domain and let that domain’s owner worry about where it’s pointed. You don’t need to 404 a domain that does not resolve to your IP address (or is accepted by your DNS as one of your domains).

Doing that with VirtualHost? IF YOU INSIST, create a VirtualHost with that domain’s name and direct it (DocumentRoot) to a subdirectory with a single file saying: This domain does NOT belong here! I would NOT mess with the port, though, as opening new ports will only create new holes for hackers!

Regards,

DK