Tyler's Site

Abstract

In modern times, the main method of posting to the Internet is using the World Wide Web, or more often known as the “Web” (for those that know the difference between the web and the Internet). However, in the 90s, there were other protocol options for having a presence online; the main alternative to web protocols was (and still is in many ways), gopher. This article will go over setting up a modern day gopher server with gophernicus.

Setting up a Gopher Server with Gophernicus

Gophernicus is a modern and full featured gopher server that is packaged in a lot of distributions, but is also very easy to build from source. For the purposes of this article, I am going to build from source.

Download and build Gophernicus from source

Building gophernicus from source is slightly more than just git clone ${thing} and make. There is a configuration step that needs to be done before-hand. See below for an example:

git clone https://github.com/gophernicus/gophernicus
cd gophernicus
./configure --listener=inetd --gopherroot=/usr/gopher
make
doas make install

The --listener=inetd and --gopherroot=/usr/gopher are customization flags that override some of the default behaviors of gophernicus. Only the --listener flag is required for the configuration script to run, but there are other options that can be defined. Reading the configure script itself will show what options are available and what the default values are. The listener option that we want for FreeBSD (host I am using for this project) is inetd. Enable inetd and start it if it is not already running:

echo 'enable_inetd="YES"' >> /etc/rc.conf
service start inetd

gophernicus itself does not actually need a service to run automatically, the inetd service will take care of that.

To test whether it is working, an application that can understand gopher will be required. There are several applications out there, such as lynx, cgo, gopher, or even Firefox with an extension called OverbiteWX. For example, using lynx:

lynx gopher://192.168.122.94

and you should get a page that looks similar to the following:

Welcome to Gophernicus!
        _______               __                      __
       |     __|.-----.-----.|  |--.-----.----.-----.|__|.----.--.--.-----
       |    |  ||  _  |  _  ||     |  -__|   _|     ||  ||  __|  |  |__ --
       |_______||_____|   __||__|__|_____|__| |__|__||__||____|_____|_____
                      |__|
       If you can see this, it means that the installation of Gophernicus
       on this system was successful. You may now add content to this
       directory and replace this page.

       Generic information:
           your ip address: 192.168.122.1
           server time....: Wed Oct  9 22:43:18 EDT 2024
           server uptime..: 51 mins
           server version.: Gophernicus/3.1.1 "Dungeon Edition"
           server platform: FreeBSD/amd64 15.0
           description....:

       Server configuration:
           config file....: /etc/inetd.conf
           server hostname: fbsd-build
           root directory.: /usr/gopher/site1
           running as user: nobody
           output charset.: UTF-8
           output width...: 67 characters

       ___________________________________________________________________
                      Gophered by Gophernicus/3.1.1 on FreeBSD/amd64 15.0

From here, you can modify the default gophermap file, as well as add your own.

Writing Gophermaps and Gopher Pages

Writing a gopher page is slightly different than writing a page for a website. The protocol is a bit more rigid than HTML, which does not allow for as much customization of the page itself. Gopher is also structured slightly differently than HTML. At least for the purposes of this post, gophernicus would only recognize gophermap files as files to display gopher properly. Because of this, I had to structure my test site as a group of folders containing a gophermap file as well as anything else that should be available on the page. I have an example below:

!Tyler's Page!

1Home   /   192.168.122.94:70

1Projects   /projects   192.168.122.94:70

1Code   /code   192.168.122.94:70

Welcome to Tyler's gopherhole

This example will render as follows using lynx:

       Tyler's Page!

 (DIR) Home

 (DIR) Projects

 (DIR) Code

       Welcome to Tyler's gopherhole
       ___________________________________________________________________
                      Gophered by Gophernicus/3.1.1 on FreeBSD/amd64 15.0

The (DIR)s are links that can be navigated through to get to other parts of the page. I found getting the gophermap file to work as I expected a bit tricky. There is a guide on the for writing gophermap files available on gophernicus’ Github, however, I still had quite a bit of trouble understanding it well enough to get the structure I wanted in my Gopher Site. As an attempt to explain this, take the following line from an example gophermap file:

1Projects   /projects   192.168.122.94:70

Each line starts with a code, which will tell the gopher protocol how to handle that particular file. For navigating to another page in the same gopher site, the only way I could get it to work and still render the gopher as gopher, is to create a directory projects in the example above, and place a new gophermap file in that directory. Then for actually creating the link, use the number code 1 (for a directory), then state the directory, /projects (yes the ‘/’ must be included as relative site references are not usually a good idea), as well as giving the IP of the server and the port number of the service.

Resources

These are some resources that I found helpful when working on this post: