Forum Moderators: phranque

Message Too Old, No Replies

VirtualHost - one seems to override the other.?

         

broniusm

10:12 pm on Nov 27, 2006 (gmt 0)

10+ Year Member



I can't figure out why ServerAlias doesn't seem to be matching domain names as expected. On this one machine, I have several domains pointing in to the same IP. One vhost config says to route a handful of domains to my Drupal directory (and Drupal then handles it properly from there). The other vhost conf files handle the remaining domains as separate, traditional vhost configs.

The three vhost sections look like this:


NameVirtualHost *
<VirtualHost *>
ServerName domain1.org
ServerAlias bvweb domain1.org domain1.net domain1.com

DocumentRoot /srv/www/htdocs/drupal/httpdocs

<VirtualHost *>
ServerName kioskhost
ServerAlias kiosk kioskdev

DocumentRoot /srv/www/htdocs/kiosk/httpdocs

<VirtualHost *>
ServerName domain2.com
ServerAlias domain2.com www.domain2.com

DocumentRoot /srv/www/htdocs/bcexpo/httpdocs

Note that the kiosk and kioskdev are known on the network (actually by my client hosts file) and are not really domains.

What works: as it stands, kiosk will work as expected, and all other domains will go to domain2. If I remove domain2, kiosk still works as expected, but Drupal (domain1) handles all requests. What gives?

On SuSE 10, I am using multiple vhost*.conf files located within /etc/apache2/vhosts.d/ so they all parse in as if they were in a single file.

broniusm

10:31 pm on Nov 27, 2006 (gmt 0)

10+ Year Member



Why is it that the "kiosk" site works fine both with the Drupal (first) vhost config and with or without the bcexpo (third) vhost config directives?

jdMorgan

4:02 am on Nov 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Too tired to think much about this right now, but I see no </VirtualHost> closing tags in your example code.

From the documentation [httpd.apache.org]:

NameVirtualHost *

<VirtualHost *>
ServerName www.domain.tld
DocumentRoot /www/domain
</VirtualHost>

<VirtualHost *>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>

Jim

broniusm

4:29 am on Nov 28, 2006 (gmt 0)

10+ Year Member



Ah, jd always monitoring the threads.. Good to have your attn again.

I maybe should have been clearer in my example code: I truncated the rather lengthy VirtualHost directives to only the lines in question and didn't bother to close them for ease of posting.

Fortunately, I have cleared my issue. I am not 100% certain what did it, but the winning combo includes explicit ServerAlias values (fully qualified domain names) And proper ServerName values And (this was probably it) entries in the web server's /etc/hosts file for the domain not yet registered.. I got to that last idea when I tried adding the domain to NameVirtualHost (not recommended, but worth a shot) which promptly gave me a warning upon apache restart. See, this machine is not free to query the DNS.. got a really strict network admin on this box.

thanks again.. Hope my follow-up helps someone in the future.