How can I tell Apache to listen ONLY on VirtualHosts?

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 ...


Go Back   Usenet Forums > Web Server and Related Forums > Linux Web Servers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-07-2005
listrecv@gmail.com
 
Posts: n/a
Default How can I tell Apache to listen ONLY on VirtualHosts?

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.

How can I do this?

  #2 (permalink)  
Old 12-07-2005
Tim
 
Posts: n/a
Default Re: How can I tell Apache to listen ONLY on VirtualHosts?

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.

  #3 (permalink)  
Old 12-09-2005
listrecv@gmail.com
 
Posts: n/a
Default Re: How can I tell Apache to listen ONLY on VirtualHosts?

Yes, I would like it to not respond at all on the default host - only
respond on virtual hosts.

  #4 (permalink)  
Old 12-16-2005
Jorey Bump
 
Posts: n/a
Default Re: How can I tell Apache to listen ONLY on VirtualHosts?

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>

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:18 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0