| Welcome to WebmasterWorld Guest from 188.8.131.52 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Become a Pro Member|
|Blocking virtual hosts that don't exist|
| 10:25 am on Mar 4, 2013 (gmt 0)|
I'd like to block (or to show an error page) to every request for a domain not present in my apache vhost configuration.
I found some domains (not in my control) which resolve to my server ip address and I don't know how to block them.
mydomain.com : 184.108.40.206
If you access externaldomain.com, apache shows the content of mydomain.com.
Thanks in advance.
| 10:19 am on Mar 7, 2013 (gmt 0)|
i haven't tested it, but something like this in the httpd.conf file (after all the other more specific VirtualHost containers) should probably do the job to create a "catch-all":
RewriteRule ^ - [F]
this should respond to any request (on port 80) for a non-specified hostname with a 403 Forbidden status code.
| 5:42 pm on Mar 7, 2013 (gmt 0)|
phranque thank you for your input, I solved the problem.
My server has 2 IP addresses and some domains on it.
The solution is adding a _default_ virtual host at the beginning, something like this:
You can check the configuration with apachectl -S
| 6:47 pm on Mar 7, 2013 (gmt 0)|
that looks like a good solution.
what's the response when the request hits the blackhole?
| 7:57 am on Mar 8, 2013 (gmt 0)|
Right now I'm just showing the Apache test page, maybe "403 unauthorized" would make more sense.
| 11:50 am on Mar 8, 2013 (gmt 0)|
you can do this in your .htaccess file, either using mod_access and a "Deny from all" directive or using mod_rewrite and the RewriteRule directive's F flag, similar to the example above.
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved