Apache Virtual Host Config Rules

Here are rules we found yesterday… the ones I can reconstruct. —Owen

“aggregate config” == the merge of all “modular” config files

  1. VirtualHost directives with port arguments () must be preceded by exactly one NameVirtualHost of the same port (:80)
    1. more than one entry of NameVirtualHost for a particular port in the aggregate config results in complaints about extraneous NameVirtualHost
    2. missing NameVirtualHost results in complaint about a VirtualHost entry taking “precedence”
  2. If a “NameVirtualHost “ is defined, then NO VirtualHost directive can designate a port; otherwise, you get complaints of extraneous NVH. (N.B. This may be implied by the Apache Httpd 2.0 documentation about how VirtualHost must exactly match corresponding NameVirtualHost). Implication: If a “NameVirtualHost *” is changed to one that designates a port, such as “NameVirtualHost *:80”, then no VirtualHost in the aggregate config can have the “” argument. (might require at least one more test to confirm)
  3. NameVirtualHost must be defined before any VirtualHost directives. Implication: vhost file names should sort such that this rule is true. (might require at least one more test to confirm)
  4. Only one default: combination for VirtualHost directive
  5. For a port, if only the default VirtualHost is defined, no NameVirtualHost is required. As soon as a second VirtualHost for the same port is defined, then a NameVirtualHost is required, and must obey rule #2.