VirtualHost precedence Apache2 5.5 (Final)

Support for webhosts that use CentOS
Post Reply
nandesu
Posts: 1
Joined: 2010/07/28 22:35:05

VirtualHost precedence Apache2 5.5 (Final)

Post by nandesu » 2010/07/28 22:46:48

Apache2 is completely ignoring the order of precedence with VirutalHost files.
I have the following real life sample replaced with example vhost names.

[code]
/etc/http/conf.d/00default.conf

<VirtualHost _default_:80>
ServerName virtualhost_example.com
ServerAlias www.virtualhost_example.com
ServerAdmin webmaster@localhost
DocumentRoot /path/here/would_be_real_in_conf
</VirtualHost>

/etc/http/conf.d/cisforchocolate.conf

<VirtualHost 192.168.1.2:80>
ServerName cisforchocolate.com
ServerAlias www.cisforchocolate.com
ServerAdmin webmaster@localhost
DocumentRoot /path/here/would_be_real_in_conf
</VirtualHost>
[/code]

If the external firewall IP address is used instead of the named host, it defaults to cisforchocolate.com instead of what is defined as "_default_".
This is causing a ton of chaos, since all customers must first update their DNS a record to point to the external IP of my webhost.
During the DNS propagation lag cisforchocolate.com is coming up instead of the default unaffiliated host.
any assistance is greatly appreciated.

Is there anything like a site-enabled / site-active such has debian has, within CentOS 5.5 Final?
I have to resolve this ASAP.

Thank you for your time and any input you may have.

logan
Posts: 64
Joined: 2008/08/01 16:40:34

VirtualHost precedence Apache2 5.5 (Final)

Post by logan » 2010/08/03 22:50:35

[quote]If the external firewall IP address is used instead of the named host, it defaults to cisforchocolate.com instead of what is defined as "_default_".[/quote]
That sounds right to me given your configuration:

http://httpd.apache.org/docs/2.2/vhosts/details.html#hostmatching
[quote]A _default_ vhost catches a request only if there is no other vhost with a matching IP address and a matching port number for the request. The request is only caught if the port number to which the client sent the request matches the port number of your _default_ vhost which is your standard Listen by default. A wildcard port can be specified (i.e., _default_:*) to catch requests to any available port. This also applies to NameVirtualHost * vhosts. Note that this is simply an extension of the "best match" principle, as a specific and exact match is favored over a wildcard.[/quote]

I also can't get [i][/i] to match when a with a specific IP address is used. I think you'll need to add another [i][/i] for virtualhost_example.com before cisforchocolate.com. Maybe you could do a more simple configuration and use [i][/i] for everything, then Allow/Deny to restrict access to vhosts that shouldn't be accessed from the outside.

Post Reply

Return to “CentOS 5 - Webhosting Support”