This is a discussion on How can I tell Apache to listen ONLY on VirtualHosts? within the Linux Web Servers forums, part of the Web Server and Related Forums category; I'd like to tell Apache to ONLY listen on IP's that have VirtualHosts, but not on any default ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On Tue, 06 Dec 2005 19:18:12 -0800, listrecv sent:
> I'd like to tell Apache to ONLY listen on IP's that have VirtualHosts, but > not on any default IP's. Also, I'd like it to be that there is not > default site, only virtual sites. It "listens" to the IP addresses that it's configured for. How it "responds" is also configurable. With a server on a fixed IP, it probably is possible to play carefully with listen and virtual host directives. But do you really not want Apache to respond to non-specified virtual hosts, at all, or just respond in some other manner? You could have some sort of error page as the response for the default server. -- If you insist on e-mailing me, use the reply-to address (it's real but temporary). But please reply to the group, like you're supposed to. This message was sent without a virus, please destroy some files yourself. |
|
|||
|
listrecv@gmail.com wrote in news:1134098061.051204.89970
@f14g2000cwb.googlegroups.com: > Yes, I would like it to not respond at all on the default host - only > respond on virtual hosts. Here's how I do it: NameVirtualHost *:80 # default virtual host catches all requests by IP or default host name # point DocumentRoot to an empty directory to always return a 404 error # deny access to return a 403 error # load this before any other virtual host files # after this is loaded, include files in virtual host directory <VirtualHost _default_:80> ServerName servername.example.net ServerAdmin admin@example.net DocumentRoot /var/www/hosts/default <Directory /var/www/hosts/default> Order allow,deny Deny from all </Directory> # inaccurate error message, but intended for human users ErrorDocument 403 "Host header is required </VirtualHost> # directory containing virtual host config files # always place after declaring default virtual host # be sure to define a default virtual host before loading these files Include conf/hosts/*.conf Each file in conf/hosts/ specifies a virtual host. conf/hosts/www.example.com.conf: <VirtualHost *:80> ServerName www.example.com ServerAdmin admin@example.net DocumentRoot /var/www/vhosts/www.example.com/site </VirtualHost> |