You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Martin Lyberg <ma...@gmail.com> on 2005/11/10 20:52:23 UTC

[users@httpd] Question regarding VirtualHosts

Hi,

I'm running Apache 2.0 on FC4. I have two websites with two domains on
the same machine. The VirtualHosts work as it should when typing
domain1.com or domain2.com.

My question is:

I only want Apache to respond with the correct site if it hits on one
of the two VirtualHosts. If i type the ip of the webserver ie:
http://ip.ip.ip.ip i get to the first VH in list. How can make Apache
only to respond if the correct domains are searched for? That means,
if none of the VirtualHosts is matched, then don't serve any site at
all.

How can this be done? This is my conf:

NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot /path/to/domain1
    ServerName domain1.com
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot /path/to/domain2
    ServerName domain2.com
</VirtualHost>

Thank you!

/ Martin

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Question regarding VirtualHosts

Posted by Martin Lyberg <ma...@gmail.com>.
On 11/10/05, Joshua Slive wrote:

> Hmmm... Did you read the FAQ entry?
>
> Anyway, to be extremely explicit, keep the exact config you already
> have but add the following immediately BEFORE the existing
> <VirtualHost> sections. This works because the first listed
> name-based virtual host catches all non-matching hostnames.
>
> <VirtualHost *:80>
> ServerName ip.ip.ip.ip
> <Location />
> Order allow,deny
> Deny from all
> Satisfy all
> </Location>
> ErrorDocument 403 "There is no website here; go away."
> </VirtualHost>


I actually did read it, but i didn't understand exactly how to do it. The
example above works perfect.

Big thanks for helping me out!

/ Martin

Re: [users@httpd] Question regarding VirtualHosts

Posted by Joshua Slive <js...@gmail.com>.
On 11/10/05, Martin Lyberg <ma...@gmail.com> wrote:
> On 11/10/05, Joshua Slive wrote:
>
> > In this example:
> >
> http://httpd.apache.org/docs/1.3/misc/FAQ.html#canonical-hostnames
> >
> > Replace the Redirect with a
> > <Location />
> > Deny from all
> > </Location>
> >
>
> Hi Joshua,
>
> I'm not quite sure i understand the syntax. Where would i put this:
>
> <Location />
> Deny from all
> </Location>
>
>  Inside both of my VHosts? The sites are two different ones, and i don't
> want a user to access any of the sites if he types the ip directly. He must
> type the correct adress to access a site.

Hmmm... Did you read the FAQ entry?

Anyway, to be extremely explicit, keep the exact config you already
have but add the following immediately BEFORE the existing
<VirtualHost> sections.  This works because the first listed
name-based virtual host catches all non-matching hostnames.

<VirtualHost *:80>
ServerName ip.ip.ip.ip
<Location />
Order allow,deny
Deny from all
Satisfy all
</Location>
ErrorDocument 403 "There is no website here; go away."
</VirtualHost>

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Question regarding VirtualHosts

Posted by Sri <gs...@yahoo.com>.
Hi,
   
   check this link www.debianhelp.co.uk/virtualhosts.htm
   
  Best Regards

Martin Lyberg <ma...@gmail.com> wrote:
  On 11/10/05, Joshua Slive wrote:  
  In this example:
http://httpd.apache.org/docs/1.3/misc/FAQ.html#canonical-hostnames

Replace the Redirect with a
<Location /> 
Deny from all
</Location>


Hi Joshua, 

I'm not quite sure i understand the syntax. Where would i put this:

<Location />
Deny from all
</Location>

Inside both of my VHosts? The sites are two different ones, and i don't want a user to access any of the sites if he types the ip directly. He must type the correct adress to access a site.

thank you

/ Martin 
  


		
---------------------------------
 Yahoo! FareChase - Search multiple travel sites in one click.  

Re: [users@httpd] Question regarding VirtualHosts

Posted by Martin Lyberg <ma...@gmail.com>.
On 11/10/05, Joshua Slive wrote:

> In this example:
> http://httpd.apache.org/docs/1.3/misc/FAQ.html#canonical-hostnames
>
> Replace the Redirect with a
> <Location />
> Deny from all
> </Location>
>

Hi Joshua,

I'm not quite sure i understand the syntax. Where would i put this:

<Location />
Deny from all
</Location>

Inside both of my VHosts? The sites are two different ones, and i don't want
a user to access any of the sites if he types the ip directly. He must type
the correct adress to access a site.

thank you

/ Martin

Re: [users@httpd] Question regarding VirtualHosts

Posted by Joshua Slive <js...@gmail.com>.
On 11/10/05, Martin Lyberg <ma...@gmail.com> wrote:
> Hi,
>
> I'm running Apache 2.0 on FC4. I have two websites with two domains on
> the same machine. The VirtualHosts work as it should when typing
> domain1.com or domain2.com.
>
> My question is:
>
> I only want Apache to respond with the correct site if it hits on one
> of the two VirtualHosts. If i type the ip of the webserver ie:
> http://ip.ip.ip.ip i get to the first VH in list. How can make Apache
> only to respond if the correct domains are searched for? That means,
> if none of the VirtualHosts is matched, then don't serve any site at
> all.
>
> How can this be done? This is my conf:
>
> NameVirtualHost *:80
>
> <VirtualHost *:80>
>     DocumentRoot /path/to/domain1
>     ServerName domain1.com
> </VirtualHost>
>
> <VirtualHost *:80>
>     DocumentRoot /path/to/domain2
>     ServerName domain2.com
> </VirtualHost>

In this example:
http://httpd.apache.org/docs/1.3/misc/FAQ.html#canonical-hostnames

Replace the Redirect with a
<Location />
Deny from all
</Location>

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org