Zeroconf is a great way for hosts and services to advertise themselves on the network. Unfortunately, Apache doesn’t provide support for advertising itself as an HTTP service out-of-the-box, so you’ll need to do some work to get it working.
There are two methods, the first use mod_dnssd which is good because it ties directly into Apache, so when Apache runs, it advertises, but when Apache is down (for whatever reason), then it stops advertising. It also means any changes you make to your Apache configuration (e.g. port) are automatically reflected in the advertisement.
The second method uses the built-in Zeroconf daemon in *nix called Avahi. Avahi is similar to Bonjour/mDNSResponder on Mac OS X and is used to advertise services to the network. By creating a basic XML file and attaching it to Avahi, your service will be advertised as long as the system is running. Using Avahi gives you the flexibility to advertise any service (not just Apache/HTTP) and is also a lot simpler to get up and running. I will outline both approaches here.
Zeroconf using mod_dnssd
- Install mod_dnssd:
sudo apt-get install libapache2-mod-dnssd
- Import the module into Apache and enable it
Open your Apache config file (e.g. /etc/apache2/apache2.conf) and add the following lines to the top:
LoadModule dnssd_module /usr/lib/apache2/modules/mod_dnssd.so
- Restart Apache with the new settings:
Zeroconf using Avahi
- Create a new file in /etc/avahi/services called http.service
- Add the following:
<?xml version="1.0" standalone='no'?> <!DOCTYPE service-group SYSTEM "avahi-service.dtd"> <service-group> <name>MyWeb</name> ## Name of the service <service> <type>_http._tcp</type> <port>80</port> </service> </service-group>
- You don’t even need to restart Avahi, your new service will automatically start broadcasting!