You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Luke Robinson <lu...@luke-robinson.co.uk> on 2006/12/08 18:47:04 UTC

[users@httpd] VirtualHost problems

Could somebody please take a look at this config - I have stripped it 
down to something close to minimal.
No hits on domain1.com seem to reach the intended (first) VirtualHost 
directive.
Hits on domain2.com reach the second VirtualHost only when not preceded 
by www.
LogLevel debug doesn't help much.

Any help would be much appreciated.
Luke Robinson
---

ServerTokens Prod
ServerRoot /home/os/httpd
PidFile run/httpd.pid
Timeout 120
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 15

LogLevel debug
ErrorLog logs/error_log

User os
Group os
UseCanonicalName Off
HostnameLookups Off
ServerSignature Off

Listen 80
NameVirtualHost 1.2.3.4:80

<VirtualHost 1.2.3.4:80>
DocumentRoot /home/os/html/domain1
ServerName www.domain1.com
</VirtualHost>

<VirtualHost 1.2.3.4:80>
DocumentRoot /home/os/html/domain2
ServerName www.domain2.co.uk
</VirtualHost>



---------------------------------------------------------------------
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] VirtualHost problems

Posted by Luke Robinson <lu...@luke-robinson.co.uk>.
Thanks for your help both of you.
In the end, my ISP was to blame, not my config :-)


Yvo van Doorn wrote:

> Thomas is right, the resources he provides are excellent. You have to 
> make sure that DNS for domain1 and domain2 are pointing to your 
> listener IP. Sometimes I have seen ISPs or people forget to add in a 
> record to have WWW point to their IP as well.
>
> If DNS is all correct and done and listening to the right IP then your 
> basic vhost configuration should look like this:
>
> <VirtualHost 1.2.3.4:80 <http://1.2.3.4/>>
> DocumentRoot /home/os/html/domain1
> ServerName www.domain1.com <http://www.domain1.com/>
> ServerAlias domain1.com <http://domain1.com>
> </VirtualHost>
>
> <VirtualHost 1.2.3.4:80 <http://1.2.3.4/>>
> DocumentRoot /home/os/html/domain2
> ServerName www.domain2.co.uk <http://www.domain2.co.uk/>
> ServerAlias domain2.co.uk <http://domain2.co.uk>
> </VirtualHost>
>
>
>
> On 12/8/06, *Luke Robinson* <luke@luke-robinson.co.uk 
> <ma...@luke-robinson.co.uk>> wrote:
>
>     Could somebody please take a look at this config - I have stripped it
>     down to something close to minimal.
>     No hits on domain1.com <http://domain1.com> seem to reach the
>     intended (first) VirtualHost
>     directive.
>     Hits on domain2.com <http://domain2.com> reach the second
>     VirtualHost only when not preceded
>     by www.
>     LogLevel debug doesn't help much.
>
>     Any help would be much appreciated.
>     Luke Robinson
>     ---
>
>     ServerTokens Prod
>     ServerRoot /home/os/httpd
>     PidFile run/httpd.pid
>     Timeout 120
>     KeepAlive Off
>     MaxKeepAliveRequests 100
>     KeepAliveTimeout 15
>
>     LogLevel debug
>     ErrorLog logs/error_log
>
>     User os
>     Group os
>     UseCanonicalName Off
>     HostnameLookups Off
>     ServerSignature Off
>
>     Listen 80
>     NameVirtualHost 1.2.3.4:80 <http://1.2.3.4:80>
>
>     <VirtualHost 1.2.3.4:80 <http://1.2.3.4:80>>
>     DocumentRoot /home/os/html/domain1
>     ServerName www.domain1.com <http://www.domain1.com>
>     </VirtualHost>
>
>     <VirtualHost 1.2.3.4:80 <http://1.2.3.4:80>>
>     DocumentRoot /home/os/html/domain2
>     ServerName www.domain2.co.uk <http://www.domain2.co.uk>
>     </VirtualHost>
>
>
>
>     ---------------------------------------------------------------------
>     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
>     <ma...@httpd.apache.org>
>        "   from the digest: users-digest-unsubscribe@httpd.apache.org
>     <ma...@httpd.apache.org>
>     For additional commands, e-mail: users-help@httpd.apache.org
>     <ma...@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] VirtualHost problems

Posted by Yvo van Doorn <yv...@gmail.com>.
Thomas is right, the resources he provides are excellent. You have to make
sure that DNS for domain1 and domain2 are pointing to your listener IP.
Sometimes I have seen ISPs or people forget to add in a record to have WWW
point to their IP as well.

If DNS is all correct and done and listening to the right IP then your basic
vhost configuration should look like this:

<VirtualHost 1.2.3.4:80 <http://1.2.3.4/>>
DocumentRoot /home/os/html/domain1
ServerName www.domain1.com
ServerAlias domain1.com
</VirtualHost>

<VirtualHost 1.2.3.4:80 <http://1.2.3.4/>>
DocumentRoot /home/os/html/domain2
ServerName www.domain2.co.uk
ServerAlias domain2.co.uk
</VirtualHost>



On 12/8/06, Luke Robinson <lu...@luke-robinson.co.uk> wrote:
>
> Could somebody please take a look at this config - I have stripped it
> down to something close to minimal.
> No hits on domain1.com seem to reach the intended (first) VirtualHost
> directive.
> Hits on domain2.com reach the second VirtualHost only when not preceded
> by www.
> LogLevel debug doesn't help much.
>
> Any help would be much appreciated.
> Luke Robinson
> ---
>
> ServerTokens Prod
> ServerRoot /home/os/httpd
> PidFile run/httpd.pid
> Timeout 120
> KeepAlive Off
> MaxKeepAliveRequests 100
> KeepAliveTimeout 15
>
> LogLevel debug
> ErrorLog logs/error_log
>
> User os
> Group os
> UseCanonicalName Off
> HostnameLookups Off
> ServerSignature Off
>
> Listen 80
> NameVirtualHost 1.2.3.4:80
>
> <VirtualHost 1.2.3.4:80>
> DocumentRoot /home/os/html/domain1
> ServerName www.domain1.com
> </VirtualHost>
>
> <VirtualHost 1.2.3.4:80>
> DocumentRoot /home/os/html/domain2
> ServerName www.domain2.co.uk
> </VirtualHost>
>
>
>
> ---------------------------------------------------------------------
> 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] VirtualHost problems

Posted by Thomas Antony <th...@antony.eu>.
> Listen 80
> NameVirtualHost 1.2.3.4:80
> 
> <VirtualHost 1.2.3.4:80>
> DocumentRoot /home/os/html/domain1
> ServerName www.domain1.com
> </VirtualHost>
> 
> <VirtualHost 1.2.3.4:80>
> DocumentRoot /home/os/html/domain2
> ServerName www.domain2.co.uk
> </VirtualHost>
> 

Hi,

Which version of apache do you have installed?
What value does the ServerName directive for the "main" server have?

When you have virtual hosts configured, the main server disappears. You
need to configure a virtual host for your main server.
You maybe also need a default virtual host or configure a virtual host
block before any other virtual host directive, which will be the default
virtual host.

<VirtualHost _default_:*>
DocumentRoot /dev/null
</VirtualHost>

If both virtual hosts should be reachable with the full qualified domain
name (without www), you must define a ServerAlias directive for each
virtual host.

http://httpd.apache.org/docs/2.0/en/vhosts/
http://httpd.apache.org/docs/2.0/en/vhosts/name-based.html
http://httpd.apache.org/docs/2.0/en/mod/core.html#virtualhost
http://httpd.apache.org/docs/2.0/en/mod/core.html#serveralias


kind regards,
Thomas


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