In association with heise online

I am legion

Apache for Mac OS X was the first web server to learn how to announce itself to Bonjour without outside help. The first Apache module called mod_rendezvous was developed for Mac OS X by Eric Seidel. STG is planning a Bonjour plugin for Internet Information Server. On Linux platforms with Avahi, the mod_dnssd module can be used to announce services. The individual steps are described in detail.

In contrast there is hardly any documentation for mod_bonjour, which Apple now includes with Mac OS X 10.4. Users running Apache on Mac OS X may initially be surprised that by default it appears to make no use of the native Bonjour module. There are two reasons for this - by default only sites from users who have edited their own websites are announced; the main site is not announced at all. Apache announcements can be quickly switched on by deleting a remark character in the httpd.conf file. By adding a little text to this file it is even possible to set up multiple announcements for the same Apache server. First open httpd.conf using a text editor such as pico. This requires administrator privileges:

sudo pico /etc/httpd.conf

After entering the administrator password, ensure that the Bonjour module is loaded at the end of the list of modules to be loaded - i.e. delete any remark character.

LoadModule bonjour_module

Further down, at the end of the "Reconstruction of the complete module list..." section, should be:

AddModule mod_bonjour.c

The end of the "VirtualHost" section should look like this; the critical lines are "RegisterResource...":

[IfModule mod_bonjour.c] 
# Only pages from users who have edited
# their default home page will be announced
RegisterUserSite customized-users
#RegisterUserSite all-users
# Announcements are disabled by default,
# so delete remark characters
# an additional entry is created for each
# optional Bonjour announcement
RegisterResource "Mini-Archiv (dz)" "/~dz/PC/"
RegisterResource "Bonjour-Tools" "/~dz/Bonjour"

After saving, restart the Apache server, for example with:

sudo apachectl restart

If everything has worked correctly, browsers with Bonjour technology will display the new announcements as separate servers in the Bonjour zone, "Mini-Archiv (dz)" and "Bonjour-Tools". There is a little known trick for persuading a Mac OS X server with multiple web servers and associated IP addresses to announce them all correctly via Bonjour.

First, you create virtual hosts. These are easy to set up using Apple's Server Admin program. The program saves the relevant entries in the /etc/httpd/sites folder. For a basic configuration, entries in the domain name, IP address and web folder fields are sufficient (see figure "Virtual host on Mac OS X"). In the options section you can also enter either Folder Listing, WebDAV, CGI Execution, WebMail or Server Side Includes, depending on the application. The Performance Cache should always be activated.

The virtual host is now in principle already accessible, using either the assigned IP address or the port entered in the /etc/httpd/sites/virtual_host_global.conf file. This file is created automatically by Server Admin according to the administrator's specifications. In the simplest case, it includes just two lines:


You then create a folder which is to contain the virtual host's web pages. In this example the virtual host is called "Portier".

sudo mkdir /Library/WebServer/Documents/Portier/
sudo chgrp www /Library/WebServer/Documents/Portier/
sudo chmod 775 /Library/WebServer/Documents/Portier/

For initial testing the index.html file from /Library/WebServer/Documents/ can be copied into this folder:

sudo cp /Library/WebServer/Documents/index.html

Bonjour support is disabled by default on Mac OS X Server 10.4. The Bonjour entries required in /etc/httpd.conf are the same as on the client version of Mac OS X ("LoadModule..." and "AddModule..."). They do not, however, have to be entered manually, rather the Bonjour module can likewise be activated using Server Admin. This is done via the "Modules" section.

A little manual work is required - the Bonjour parameters for the virtual host must be added to the end of the httpd.conf file:

[IfModule mod_bonjour.c]
# Only pages from users who have edited
# their default home pages will be announced
RegisterUserSite customized-users
# RegisterUserSite all-users
# Bonjour announcements are disabled by default
# so delete remark characters
# and now register the virtual uses with Bonjour
RegisterResource "iCals" "/iCals" 16080
RegisterResource "Portier" "/Portier" 16080

It should be noted that Server Admin rewrites /etc/httpd.conf every time the web server settings are saved and may occasionally overwrite manual entries such as the above in doing so. (rek)

Print Version | Permalink:
  • Twitter
  • Facebook
  • submit to slashdot
  • StumbleUpon
  • submit to reddit

  • July's Community Calendar

The H Open

The H Security

The H Developer

The H Internet Toolkit