You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Selmer Ausland <se...@shawcable.com> on 2003/01/05 15:47:14 UTC

[users@httpd] Virtual Hosts

Hello Group;

    I am running Apache 2.0.43 on Win NT 4.0. and I am running a number
of virtual hosts, all name based. All of the webpages are served up
normally, but I have a problem.

In my web browser, I can view my domain http://www.abcd.com/

I can also view www.abcd.com/ 

However, in my web browser, abcd.com or abcd.com/ gives me a page not
found error.

This same problem is affecting all of my virtual hosts in the same way,
except for the following:

If I enter http://www.efgh.com/ it works.

If I enter www.efgh.com/ it works.

But, if I enter efgh.com it goes to http://abcd.com (my domain), (not
http://www.abcd.com ??)

Below is a sample of my VirtualHost config. Can anyone enlighten me as
to what I am doing wrong? 

Listen 80 (I have also tried Listen xx.xx.xxx.xxx:80)

<VirtualHost *>
     ServerAdmin webmaster@abcd.com
     DocumentRoot "E:/Apache2/htdocs"
     ServerName www.abcd.com
     ErrorLog  logs/abcd.com-error_log
     CustomLog logs/abcd.com-access_log common
     <Directory "E:/Apache2/htdocs">
     Options Indexes
     AllowOverride AuthConfig Options Fileinfo
     Order Allow,Deny
     Allow from all
     </Directory>
</VirtualHost>

<VirtualHost *>
     ServerAdmin webmaster@efgh.com
     DocumentRoot "E:/Apache2/htdocs/efgh"
     ServerName www.efghsqn.com
     ErrorLog  logs/efgh.com-error_log
     CustomLog logs/efgh.com-access_log common
     <Directory "E:/Apache2/htdocs/efgh">
     Options Indexes
     AllowOverride AuthConfig Options Fileinfo
     Order Allow,Deny
     Allow from all
     </Directory>
</VirtualHost>

Thanks, I would appreciate any help you can give.

Selmer Ausland

---------------------------------------------------------------------
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] Virtual Hosts

Posted by Rich Bowen <rb...@rcbowen.com>.
On Sun, 5 Jan 2003, Jeff Cohen wrote:

> For me it works!!
> Listen 80
> NameVirtualHost 216.138.220.213
>
> <VirtualHost *.starford.ca>
>     ServerAdmin admin@starford.ca
>     ServerName Starford.ca
>     ServerAlias starford.ca *.starford.ca
> ......
> </VirtualHost>
>
>
> <VirtualHost *.gej-it.com>
>     ServerAdmin admin@gej-it.com
>     ServerName GEJ-IT
>     ServerAlias gej-it.com *.gej-it.com
> ......
> </VirtualHost>
>
> Check it!

Then perhaps I should rephrase. This syntax is undefined, and not
guaranteed to work in any future versions. It is actively discouraged in
the documentation. If it works for you, great. You got lucky. Please
don't encourage other people to use this syntax.

The argument to VirtualHost, when using name-based vhosting, should be
either an IP address or *, optionally followed by :port (eg :8080).

-- 
Rich Bowen
Apache - mod_perl - Perl - CGI
http://www.ApacheAdmin.com/


---------------------------------------------------------------------
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] Virtual Hosts

Posted by Jeff Cohen <ap...@gej-it.com>.
For me it works!!
Listen 80
NameVirtualHost 216.138.220.213

<VirtualHost *.starford.ca>
    ServerAdmin admin@starford.ca
    ServerName Starford.ca
    ServerAlias starford.ca *.starford.ca
......
</VirtualHost>


<VirtualHost *.gej-it.com>
    ServerAdmin admin@gej-it.com
    ServerName GEJ-IT
    ServerAlias gej-it.com *.gej-it.com
......
</VirtualHost>

Check it!
Jeff Cohen

> -----Original Message-----
> From: Rich Bowen [mailto:rbowen@rcbowen.com]
> Sent: Sunday, January 05, 2003 1:22 PM
> To: users@httpd.apache.org
> Subject: RE: [users@httpd] Virtual Hosts
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On Sun, 5 Jan 2003, Jeff Cohen wrote:
> 
> > Try putting the servers names on the virtual host itself:
> >
> > Listen 80
> > NameVirtualHost 1.2.3.4
> >
> > <VirtualHost abcd.com>
> > ServerAlias abcd.com *.abcd.com
> > ...
> > </VirtualHost>
> >
> > <VirtualHost efgh.com>
> > ServerAlias efgh.com *.efgh.com
> > ...
> > </VirtualHost>
> 
> No, don't do that. That won't work, and is specifically recommended
> against in the documentation. The argument to NameVirtualHost *MUST*
be
> exactly the same as the argument to VirtualHost.
> 
> - --
> Oh I have slipped the surly bonds of earth
> And danced the sky on laughter-silvered wings
>  --High Flight (John Gillespie Magee)
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.1 (GNU/Linux)
> Comment: Made with pgp4pine 1.75-6
> 
> iD8DBQE+GHfBXP03+sx4yJMRAnplAKCXerBGU7NuGkDMcL4aRjYgZOgGZwCgwwD9
> 5NqexDwCEy3Y6kgKozkr9E4=
> =xBfx
> -----END PGP SIGNATURE-----
> 
> 
> 
> ---------------------------------------------------------------------
> 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


---------------------------------------------------------------------
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] Virtual Hosts

Posted by Rich Bowen <rb...@rcbowen.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, 5 Jan 2003, Jeff Cohen wrote:

> Try putting the servers names on the virtual host itself:
>
> Listen 80
> NameVirtualHost 1.2.3.4
>
> <VirtualHost abcd.com>
> ServerAlias abcd.com *.abcd.com
> ...
> </VirtualHost>
>
> <VirtualHost efgh.com>
> ServerAlias efgh.com *.efgh.com
> ...
> </VirtualHost>

No, don't do that. That won't work, and is specifically recommended
against in the documentation. The argument to NameVirtualHost *MUST* be
exactly the same as the argument to VirtualHost.

- -- 
Oh I have slipped the surly bonds of earth
And danced the sky on laughter-silvered wings
 --High Flight (John Gillespie Magee)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Made with pgp4pine 1.75-6

iD8DBQE+GHfBXP03+sx4yJMRAnplAKCXerBGU7NuGkDMcL4aRjYgZOgGZwCgwwD9
5NqexDwCEy3Y6kgKozkr9E4=
=xBfx
-----END PGP SIGNATURE-----



---------------------------------------------------------------------
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] Virtual Hosts

Posted by Jeff Cohen <ap...@gej-it.com>.
Try putting the servers names on the virtual host itself:

Listen 80
NameVirtualHost 1.2.3.4

<VirtualHost abcd.com>
ServerAlias abcd.com *.abcd.com
...
</VirtualHost>

<VirtualHost efgh.com>
ServerAlias efgh.com *.efgh.com
...
</VirtualHost>

Good Luck,
Jeff Cohen


> -----Original Message-----
> From: Selmer Ausland [mailto:sel.ausland@shawcable.com]
> Sent: Sunday, January 05, 2003 9:47 AM
> To: users@httpd.apache.org
> Subject: [users@httpd] Virtual Hosts
> 
> Hello Group;
> 
>     I am running Apache 2.0.43 on Win NT 4.0. and I am running a
number
> of virtual hosts, all name based. All of the webpages are served up
> normally, but I have a problem.
> 
> In my web browser, I can view my domain http://www.abcd.com/
> 
> I can also view www.abcd.com/
> 
> However, in my web browser, abcd.com or abcd.com/ gives me a page not
> found error.
> 
> This same problem is affecting all of my virtual hosts in the same
way,
> except for the following:
> 
> If I enter http://www.efgh.com/ it works.
> 
> If I enter www.efgh.com/ it works.
> 
> But, if I enter efgh.com it goes to http://abcd.com (my domain), (not
> http://www.abcd.com ??)
> 
> Below is a sample of my VirtualHost config. Can anyone enlighten me as
> to what I am doing wrong?
> 
> Listen 80 (I have also tried Listen xx.xx.xxx.xxx:80)
> 
> <VirtualHost *>
>      ServerAdmin webmaster@abcd.com
>      DocumentRoot "E:/Apache2/htdocs"
>      ServerName www.abcd.com
>      ErrorLog  logs/abcd.com-error_log
>      CustomLog logs/abcd.com-access_log common
>      <Directory "E:/Apache2/htdocs">
>      Options Indexes
>      AllowOverride AuthConfig Options Fileinfo
>      Order Allow,Deny
>      Allow from all
>      </Directory>
> </VirtualHost>
> 
> <VirtualHost *>
>      ServerAdmin webmaster@efgh.com
>      DocumentRoot "E:/Apache2/htdocs/efgh"
>      ServerName www.efghsqn.com
>      ErrorLog  logs/efgh.com-error_log
>      CustomLog logs/efgh.com-access_log common
>      <Directory "E:/Apache2/htdocs/efgh">
>      Options Indexes
>      AllowOverride AuthConfig Options Fileinfo
>      Order Allow,Deny
>      Allow from all
>      </Directory>
> </VirtualHost>
> 
> Thanks, I would appreciate any help you can give.
> 
> Selmer Ausland
> 
> ---------------------------------------------------------------------
> 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


---------------------------------------------------------------------
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] Virtual Hosts

Posted by Selmer Ausland <se...@shawcable.com>.
Thanks Rich. I have found the problem, now trying to fix it. Appreciate
your help.

Selmer Ausland


Rich Bowen wrote:
> 
> On Sun, 5 Jan 2003, Selmer Ausland wrote:
> 
> > Hello Group;
> >
> >     I am running Apache 2.0.43 on Win NT 4.0. and I am running a number
> > of virtual hosts, all name based. All of the webpages are served up
> > normally, but I have a problem.

---------------------------------------------------------------------
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] Virtual Hosts

Posted by Rich Bowen <rb...@rcbowen.com>.
On Sun, 5 Jan 2003, J. Greenlees wrote:

> would not aliasing www.abcd.com to abcd.com allow it to work without the
> dns entry?
> I know it can be aliased, but not sure about the dns.

No, it would not. If the name does not resolve to the IP address, in
DNS, then the browser will never find your server in the first place.
When you type a hostname into your browser, the first thing that it must
do is query DNS to find out where that server lives, by IP Address.
Putting virtual host configurations in Apache does not make that name
resolve to that server. If it did, then surely we could all set up
www.microsoft.com virtual hosts and hijack the real site.

HTTP relies on DNS, and vhosts don't work without DNS entries.

-- 
And everyone said, "If we only live,
We too will go to sea in a Sieve -
To the hills of the Chankly Bore!"
 (The Jumblies, by Edward Lear)


---------------------------------------------------------------------
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] Virtual Hosts

Posted by "J. Greenlees" <ja...@shaw.ca>.

Rich Bowen wrote:
> On Sun, 5 Jan 2003, Selmer Ausland wrote:
> 
> 
>>Hello Group;
>>
>>    I am running Apache 2.0.43 on Win NT 4.0. and I am running a number
>>of virtual hosts, all name based. All of the webpages are served up
>>normally, but I have a problem.
>>
>>In my web browser, I can view my domain http://www.abcd.com/
>>I can also view www.abcd.com/
> 
> 
> Those two things are not different. The browser assumes http://
> 
> 
>>However, in my web browser, abcd.com or abcd.com/ gives me a page not
>>found error.
> 
> 
> That is a different hostname, and must be in DNS as a separate record.
> Neither DNS, nor Apache, nor your browser, think of them as being the
> same hostname. Make sure that you have an entry in your name server for
> both hostnames.

would not aliasing www.abcd.com to abcd.com allow it to work without the 
dns entry?
I know it can be aliased, but not sure about the dns.
>>Listen 80 (I have also tried Listen xx.xx.xxx.xxx:80)
>>
>><VirtualHost *>
>>     ServerAdmin webmaster@abcd.com
>>     DocumentRoot "E:/Apache2/htdocs"
>>     ServerName www.abcd.com
> 
> ServerAlias abcd.com
> 
> Adding that ServerAlias entry will make it answer to that hostname as
> well. That is, assuming that the name correctly resolves in DNS.
> 
> Likewise, here:
> 
>><VirtualHost *>
>>     ServerAdmin webmaster@efgh.com
>>     DocumentRoot "E:/Apache2/htdocs/efgh"
>>     ServerName www.efghsqn.com
> 
> ServerAlias efghsqn.com
> 
> Hope this helps
> 



---------------------------------------------------------------------
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] Virtual Hosts

Posted by Rich Bowen <rb...@rcbowen.com>.
On Sun, 5 Jan 2003, Selmer Ausland wrote:

> Hello Group;
>
>     I am running Apache 2.0.43 on Win NT 4.0. and I am running a number
> of virtual hosts, all name based. All of the webpages are served up
> normally, but I have a problem.
>
> In my web browser, I can view my domain http://www.abcd.com/
> I can also view www.abcd.com/

Those two things are not different. The browser assumes http://

> However, in my web browser, abcd.com or abcd.com/ gives me a page not
> found error.

That is a different hostname, and must be in DNS as a separate record.
Neither DNS, nor Apache, nor your browser, think of them as being the
same hostname. Make sure that you have an entry in your name server for
both hostnames.

> But, if I enter efgh.com it goes to http://abcd.com (my domain), (not
> http://www.abcd.com ??)

You need to make sure that all possible hostnames are listed in
ServerAlias records. If the hostname does not exactly match, you will
get the default (ie, first) virtual host.

> Below is a sample of my VirtualHost config. Can anyone enlighten me as
> to what I am doing wrong?
>
> Listen 80 (I have also tried Listen xx.xx.xxx.xxx:80)
>
> <VirtualHost *>
>      ServerAdmin webmaster@abcd.com
>      DocumentRoot "E:/Apache2/htdocs"
>      ServerName www.abcd.com
ServerAlias abcd.com

Adding that ServerAlias entry will make it answer to that hostname as
well. That is, assuming that the name correctly resolves in DNS.

Likewise, here:
> <VirtualHost *>
>      ServerAdmin webmaster@efgh.com
>      DocumentRoot "E:/Apache2/htdocs/efgh"
>      ServerName www.efghsqn.com
ServerAlias efghsqn.com

Hope this helps

-- 
Rich Bowen - rbowen@rcbowen.com
As we trace our own few circles around the sun
We get it backwards and our seven years go by like one
	Dog Years (Rush - Test for Echo - 1999)


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