Configure Bonjour for a custom vhost on Apache on OS X

Bonjour is a lovely technology. I would like all my custom vhosts on my mac (Snow Leopard) to broadcast via bonjour. What is the best way to do this, without having to enable for every vhost separately?


Solution 1:

I'm going to be making the assumption you're using the built-in Apache Server, so...

If you open up your httpd.conf you can usually see at the very bottom:

Include /private/etc/apache2/other/*.conf

The "other" directory contains both php.conf and bonjour.conf

Bonjour.conf has a few oddities though, for one, the default file does not include some of the possible options. As far as I know there are only three possible options:


RegisterDefaultSite

This broadcasts the main site, not a VHost, and uses the machine's name (As defined by "Computer Name" in the sharing prefs) as the Bojour service title.


RegisterUserSite

this takes one of three options:

<a username>
all-users
customized_users

The first two are self explanatory, but customized_users is rather clever; it checks if each user has made changes to the index.html in ~/Sites; if so, that user's page is broadcasted.


RegisterResource

This is probably the one you are looking for; it accepts two arguments, a service name and a path.

Ex:

RegisterResource HelloLan /

My suggestion:

I would try placing a RegisterResource in each VHost, although I don't use VHosts and so I haven't tried it myself.

I have heard the the mod_bonjour that is shipped by default has some issues with multiple RegisterResource options see here: http://deeperdesign.wordpress.com/2010/06/13/apples-mod_bonjour-is-broken-in-snow-leopard-so-i-fixed-it/.

Someone leaving a comment on the aforementioned page seemed to suggest VHost Bonjour is possible.

so best of luck!