[Intrepid Alpha 5 through Live release] NameVirtualHost entry in ports.conf causes "NameVirtualHost *:80 has no VirtualHosts" warning and breaks virtualhosts

Bug #268868 reported by Dax Solomon Umaming
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
apache2 (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Binary package hint: apache2

I've setup a sandbox and configured VirtualHosts.
I noticed that NameVirtualHost has an entry in /etc/apache2/ports.conf
I've configured /etc/apache2/sites-available/default and added a few more VirtualHost entries there but reload only gave me a warning:
[Thu Sep 11 15:05:04 2008] [warn] NameVirtualHost *:80 has no VirtualHosts

Here's my /etc/apache2/sites-available/default file:

NameVirtualHost *
<VirtualHost *>
        DocumentRoot "/var/www"
        ServerName localhost
</VirtualHost>
<VirtualHost *>
        DocumentRoot "/home/dax/Codes/OMS"
        ServerName oms
</VirtualHost>
<VirtualHost *>
        DocumentRoot "/home/dax/Codes/Ticketing"
        ServerName ticketing
</VirtualHost>

Servers ticketing and oms are both pointed at 127.0.0.1 on /etc/hosts and this setup should've worked. However, no matter what server I access, I always end up at /var/www.

I soon found out that /etc/apache2/ports.conf has NameVirtualHost entry:

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default

NameVirtualHost *:80
Listen 80

<IfModule mod_ssl.c>
    # SSL name based virtual hosts are not yet supported, therefore no
    # NameVirtualHost statement here
    Listen 443
</IfModule>

I commented out NameVirtualHost and got my oms and radio servers working after reload.

Revision history for this message
Stefan Fritsch (sf-sfritsch) wrote :

This is documented in NEWS.Debian. Maybe an entry in the release notes is needed, too?

Revision history for this message
Dax Solomon Umaming (knightlust) wrote :

I guess it is documented in NEWS.Debian, but I didn't read it. I suggest a comment on /etc/apache2/sites-available/default since that what Admins configure first. And most of the admins I know don't read docs.

Revision history for this message
gCg (guney) wrote :

Thanks Dax, commenting out NameVirtualHost *:80 line at /etc/apache2/ports.conf fixed the problem for me too.

Revision history for this message
Tchalvak (tchalvak) wrote :

My upgrade to Intrepid Ibex added a ports.conf to the apache files,
containing the lines
NameVirtualHost:80
Listen 80

(and some ssl stuff).

this gave the error: [warn] NameVirtualHost *:80 has no VirtualHosts
when I restarted apache, and sent all my pre-existing virtualhost entries to the default /var/www/ localhost location.

Just commenting out the NameVirtualHost line didn't solve the problem for me, my solution ended up being making the NameVirtualHost and default virtual host MATCH port settings by:

Stripping the :80 port reference from the NameVirtualHost *:80 line in ports.conf and also stripping the :80 port reference from the default virtual host <VirtualHost *:80> as well, so now both looked like:

NameVirtualHost *

... and ...

<VirtualHost *>

And now my other virtualhosts are working again.

Revision history for this message
Tchalvak (tchalvak) wrote :

I should add that this was with the Live release of Ubuntu Intrepid Ibex, not the alpha.

Revision history for this message
Ryan Niebur (ryan52) wrote :

Hi Glassbox,

The correct fix is to change all of your "<VirtualHost *>" to "<VirtualHost *:80>". Please see /usr/share/doc/apache2/NEWS.Debian.gz for more information.

Thanks,
Ryan

Revision history for this message
Tchalvak (tchalvak) wrote :

Yep, figures that you can sync 'em up either way, with the ports or without. It just seems kinda buggy in that it breaks what was previously working to allow the -potential- for ssl virtual hosts. Seems like at least a simple change to documentation in the new ports.conf file along the lines of the documentation below, saying something like "Match all appropriate <VirtualHost *> entries to VirtualHost *:80> to correspond with the NameVirtualHost *:80" would make explicit the change as opposed to just introducing a new warning without documenting the solution. :p

From the NEWS.Debian documentation:
apache2 (2.2.9-3) unstable; urgency=low

  * The directive "NameVirtualHost *" has been changed to "NameVirtualHost
    *:80". It has also been moved from sites-available/default to ports.conf.
    This allows to ship a proper SSL default virtual host config in
    sites-available/default-ssl, but it means that if you use several name
    based virtual hosts:

    - you will have to change <VirtualHost *> to <VirtualHost *:80> in your
      name based virtual hosts

    - you need to add more NameVirtualHost directives if you use other ports
      than 80 with name based virtual hosts. You may also have to add these
      ports to the default virtual host in /etc/apache2/sites-available/default
      (like this: "<VirtualHost *:80 *:81>").

    If you prefer to revert to the old setup instead (and don't need the
    default-ssl host), just change "NameVirtualHost *:80" back to
    "NameVirtualHost *" in ports.conf and "<VirtualHost *:80>" to
    "<VirtualHost *>" in sites-available/default.

  * For mod_disk_cache, caching is again disabled in disk_cache.conf by
    default. It usually makes more sense to enable this on a per-virtual host
    basis.

 -- Stefan Fritsch <email address hidden> Mon, 30 Jun 2008 19:47:52 +0200

Revision history for this message
Chuck Short (zulcss) wrote :

This bug report is being closed due to your last comment regarding this being fixed with an update. For future reference you can manage the status of your own bugs by clicking on the current status in the yellow line and then choosing a new status in the revealed drop down box. You can learn more about bug statuses at https://wiki.ubuntu.com/Bugs/Status. Thank you again for taking the time to report this bug and helping to make Ubuntu better. Please submit any future bugs you may find.

Changed in apache2 (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.