Dear Wiki user, You have subscribed to a wiki page or wiki category on "Httpd Wiki" for change notification.
The following page has been changed by megaspaz: http://wiki.apache.org/httpd/ScratchPad/CommonMisconfigurations New page: = Common Apache Misconfigurations = This page will describe common misconfigurations as seen in #apache as well as describe why these are wrong. === Name Based Virtual Host === 1. Not matching the value of !NameVirtualHost with a corresponding <!VirtualHost> block.[[BR]] Example: {{{NameVirtualHost *:80 # This is wrong. <VirtualHost some.domain.com> # Options and stuff defined here. </VirtualHost> # This would be correct. <VirtualHost *:80> ServerName some.domain.com # Options and stuff defined here. </VirtualHost> }}} Why is the first virtual host wrong? It's wrong on a couple of levels. The most obvious is that some.domain.com used in the first <!VirtualHost> block doesn't match *:80 used in !NameVirtualHost. The other being that NameVirtualHost refers to an interface, not a domain. For instance using *:80, means catch all interfaces on port 80. !NameVirtualHost 1.1.1.1:80, would mean to catch the interface defined as 1.1.1.1 on port 80. While you can use a "!NameVirtualHost some.domain.com/<!VirtualHost some.domain.com>" combination, it doesn't really make sense and is not used... at least not used by anyone who's experienced with Apache administration.[[BR]][[BR]] 2. Not setting a !ServerName in a virtual host.[[BR]] Example: {{{NameVirtualHost *:80 # This would be correct. <VirtualHost *:80> ServerName some.domain.com # Options and stuff defined here. </VirtualHost> # This is wrong. <VirtualHost *:80> # Options and stuff defined here, but no ServerName </VirtualHost> }}} The second virtual host is wrong because when using name based virtual hosts, the !ServerName is used by Apache to determine which virtual host configuration to use. Without it, Apache will never use the second virtual host configuration and will use the default virtual host. The default virtual host when using name based virtual hosts is the first defined virtual host.[[BR]][[BR]] 3. Mixing !NameVirtualHost * with !NameVirtualHost *:<some port>.[[BR]] Example: {{{NameVirtualHost * NameVirtualHost *:80 <VirtualHost *> ServerName some.domain.com # Options and stuff defined here. </VirtualHost> <VirtualHost *:80> ServerName some.domain2.com # Options and stuff defined here. </VirtualHost> }}} Because !NameVirtualHost * means catch on all interfaces on all ports, the *:80 virtual host will never be caught. Every request will to Apache will result in the some.domain.com virtual host being used.
