[gopher] Implementing named-based virtual hosts with buckd/xinetd

Brian Koontz brian at pongonova.net
Fri Jul 15 19:53:28 UTC 2011


xinetd does not offer true name-based virtual host capability (i.e.,
the ability to differentiate between different hostnames used to
access the same service).  This makes sense, since xinetd is bound by
ip address and port.

As part of the OpenNIC project, I was interested in having my gopher
server respond based upon the hostname that was used to access.
Otherwise, the selector hosts would simply default to whatever $MYHOST
was set to in buckd.

It turns out the solution to this problem is quite simple, provided
you have two hostnames that resolve to two different IP addresses.
Basically, you tell xinetd to listen for connections to both
addresses, and depending upon which address is used, a hostname string
is sent to buckd so that the selectors match the hostname.

For this example, I'll use the following hostname->IP mappings:

pongonova.org -> 66.244.95.11
pongonova.gopher -> 66.244.95.20

1.  buckd requires one change...replace the $MYHOST line (line 22) with
the following:

$MYHOST ||= $ARGV[0] || "pongonova.org" 

2.  Copy your "service buckd" configuration in /etc/xinetd.conf.  I
believe the services must be named differently; I simply used "service
buckd-gopher" and "service buckd-org".

3.  In each configuration, add a new parameter, "bind", that
associates a particular configuration with a specific IP address.
Also, add the corresponding hostname to the end of the server_args
parameter value:

service buckd-gopher
{
   bind = 66.244.95.20
   ...
   server_args = -j /chroot/buckd -x /chroot/buckd/usr/local/bin/buckd
--user gopher --group gopher -- pongonova.gopher
}

service buckd-org
{
   bind = 66.244.95.11
   ...
   server_args = -j /chroot/buckd -x /chroot/buckd/usr/local/bin/buckd
--user gopher --group gopher -- pongonova.org
}

5.  SIGHUP to your xinetd process to reread the new changes.

You can see it in action here:

gopher://pongonova.org
gopher://pongonova.gopher (you'll need to be pointing to an OpenNIC
server to resolve this; feel free to use mine, 66.244.95.20)

  --Brian

--
Don't have gopher?  Visit the world's first wiki-based gopher proxy!
http://www.pongonova.org/gopherwiki
IRC: Freenode.net channel #gopherproject



More information about the Gopher-Project mailing list