phranque

msg:4552051 | 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": <VirtualHost *:80> ServerName _default_ ServerAlias * DocumentRoot /usr/web/wildcard/htdocs RewriteEngine on RewriteRule ^ - [F] </VirtualHost>
|
| this should respond to any request (on port 80) for a non-specified hostname with a 403 Forbidden status code.
|
teokolo

msg:4552219 | 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: NameVirtualHost 1.1.1.1 <VirtualHost 1.1.1.1> ServerName _default_ DocumentRoot /var/www/html/blackhole </VirtualHost> <VirtualHost 1.1.1.1> ServerName example.com DocumentRoot /var/www/html/example.com </VirtualHost> NameVirtualHost 2.2.2.2 <VirtualHost 2.2.2.2> ServerName _default_ DocumentRoot /var/www/html/blackhole </VirtualHost> <VirtualHost 2.2.2.2> ServerName example2.com DocumentRoot /var/www/html/example2.com </VirtualHost> |
| You can check the configuration with apachectl -S
|
phranque

msg:4552255 | 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?
|
teokolo

msg:4552465 | 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.
|
phranque

msg:4552533 | 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.
|
|