This is as days pass by, by Stuart Langridge

And this is Auto-discoverable local websites, written , and concerning Web, Sundry Hacks, and Linux

Epiphany, the Gnome web browser, has a nice feature where it will automatically discover websites on your local network and add them to your bookmarks list. It occurred to me that this would be useful for a workshop I'm running later this week; have some materials in a website, and then everyone at the workshop will just have it appear in their bookmarks. Well, they will if they're using Epiphany, or Konqueror, and (since most of them will likely be Mac people) they will in Safari as well (I think). So, I thought: I want a piece of that action. I want to create such a website and have Safari etc pick it up. But how do you do that? Ross Burton to the rescue; Ross explains how to advertise a website over Zeroconf (Bonjour for Mac people, but it's all the same technology). So, just drop a file in that /etc/avahi/services folder and it all works. And then I thought: how do I test it works? (I don't use Epiphany, I use Firefox.) BonjourFoxy to the rescue too; it browses the local network for websites that are so advertised and displays them in a sidebar; works for all platforms. So, this oughta work. (People with both Macs and Ubuntu; I'd appreciate it if you could use Ross's docs to advertise a local webpage with a specific path on the Ubuntu box and then see if Safari on the Mac picks it up.)

Comments

Kjetil T

I've been doing this for a while and it does indeed work with Safari. However safari only picks up services with type _http._tcp, while epiphany also picks up _https._tcp services.

Roger

BonjourFoxy link is wrong fwiw.

Ben Asselstine

Can you post the file that you put in /etc/avahi/services ?

Simon McVittie

Kjetil T: that's correct behaviour, according to the RFC-draft for mDNS (it halves the number of queries, and people wanting to publish https sites can just publish a http site that redirects to the https one).

See also mod_dnssd:

http://0pointer.de/lennart/projects/mod_dnssd/

http://packages.qa.debian.org/m/mod-dnssd.html

sil

Roger: thanks, fixed.

Ben:

$ cat /etc/avahi/services/web.service

<?xml version="1.0" standalone='no'?>

<!DOCTYPE service-group SYSTEM "avahi-service.dtd">

<service-group>

<name>FOWD 2009</name>

<service>

<type>_http._tcp</type>

<port>80

<txt-record>path=/~aquarius/fowd2009/</txt-record>

</service>

</service-group>

glandium

Sadly, (at least) epiphany does the wrong thing when going to the website, going to http://ip instead of http://name, which break virtualhosting.

Mats Taraldsvik

Zeroconf continues to impress!

sil: is missing from that file?

Mats Taraldsvik

Should be: is "tagstart" "slash" port "tagend" missing from web.service ?

oliver

Btw. is it also possible to publish URLs to completely different servers, or can you only publish URLs that are on the same server where Avahi is running? I haven't found any conclusive answer yet and would be grateful for some insights :-)

sil

Mats: yes, it is. Sorry :)

oliver: I don't know. There's a suggestion in Ross's post that that feature was coming (and that was written in 2006), so I believe so, I've jst never done it.

Andrew TJ

sil: Thanks for the positive feedback on BonjourFoxy :)

oliver: You can advertise a service on behalf of another machine - here's an example:

Example Website

example.com

_http._tcp.

80

path=/

If an mDNS hostname needs to be created for the machine it can be added to '/etc/avahi/hosts' although there is a few limitations with this method.

Andrew TJ

The formatting for the example got chewed up so I have posted it here: http://andrew.tj.id.au/files/example-avahi-service.txt

oliver

Andrew: thanks for the example! I have tried it, but Ubuntu 9.04 can't resolve the host name (avahi-browse-domains -a -t -r does not give an IP for example.com). Do I have to add example.com to /etc/avahi/hosts even though its IP is available in normal DNS?

sil

oliver: you should replace example.com with the hostname of the machine that's exporting the service you want to advertise.

oliver

Well I want to advertise some site that's on the Internet - something like a LAN-wide bookmark. Isn't that possible?

sil

oliver: ah. I don't know whether that's possible or not. Andrew might know. :)

Andrew TJ

oliver: There shouldn't be any need to add records for a host that can already be resolved (whether it be via mDNS or DNS).

This is a snip from the output of 'avahi-browse-domains -a -t -r' on my system with the previous example active:

= eth0 IPv4 Example Website Web Site local

hostname = [example.com]

address = [208.77.188.166]

port = [80]

txt = ["path=/"]

Perhaps 'avahi-browse-domains -a -t -r -d dns-sd.org' might show if Avahi's having problems with unicast DNS for some reason?

oliver

Andrew: that's a good example. On Debian Lenny avahi-browse-domains -a -t -r -d dns-sd.org gives lots of resolved Internet-wide host names while on the Ubuntu Jaunty system it gives no output at all (resolving .local addresses works fine, though). Maybe it's a setup problem in my LAN or on the Jaunty system - will do some more checking. Thanks for your pointers!

This website belongs to Stuart Langridge. Contact details are available. Don't eat yellow snow. Valid HTML5, at least in theory, except for the bits that aren't because I'm that futuristic that I'm ahead of the spec, oh yes. HTML5 help from Bruce Lawson, among others. Fonts from the superb FontSquirrel. End.