Gopher

Fri, 31 Jan 2025 18:41:50 -0500

For those unaware, HTTP/HTTPS are not the only protocols for sending data over a network. Most people are familiar protocols like FTP and SSH to name a few, but there are other interesting protocols that. One such protocol is Gopher. Developed by the University of Minnesota in 1991, Gopher allowed users to create simple, plain-text pages (akin to simple websites) and share them with each other. Unfortunately for Gopher's sake, it came out only a few years before HTTP, and up its release, Gopher was unceremoniously swept into the dust-bin of tech history.

While Gopher is in many ways a historical oddity, it is still alive and active today. There remains a small (but active) network of Gopher servers, and you can view them if you want. Gopher links look a lot like web links, but instead of being prefixed with http:// or https://, they are prefixed with gopher://.

For example, my Gopher site is gopher://gopher.matl.me. However, you will quickly notice that if you try and put this in a modern web browser, you will not be able to view the site. Despite being a simple protocol, most modern web browsers do not support Gopher.

There are some in browser emulators like floodgap, but in my opinion, it's best to browse gopherspace using traditional text based browsers like Lynx. In fact, Lynx has built in gopher support. All you need to do is pass the domain name with the gopher:// prefix, and you should be able to view any gopher site.

 $ lynx <gopher://domain.tdl>

A note about security

It is important to note that Gopher (like HTTP) does not support encryption, so data is transferred to and from the server in plain text. This said, Gopher sites are mostly plain text blogs, but just be wary and know that your Gopher searches are not private.

Host your own Gopherhole!

As a graduate of the University of Minnesota, I simply had to have my own Gopher server. To get started, you can serve your Gopher site locally just to mess around, but if you want to make your Gopher site public, you can always rent a cheap VPS. If you want your Gopher site to be on the internet, I will assume that you have a base level knowledge of Linux and server administration.

firewall note

If you already have a VPS set up with firewall, make sure to open port 70. You can change what port your site is served over if you want, but the default for Gopher sites is 70.

 # ufw allow 70

gopher server

I am currently using the Motsognir Gopher server. I am currently using an Arch server, so I will be using the package available in the AUR. If you have never installed an AUR package, make sure that you have the base-devel package installed on your system. This package contains a bunch of tools that allow you to build Arch packages.

 # pacman -S base-devel
 $ git clone "https://aur.archlinux.org/motsognir.git" 

Unzip the archive, and cd into he new directory.

 $ tar -xvf motsognir.tar.gz && cd motsognir

Run the following command to build the package and prepare it for installation using pacman (note that you should not run this command as root).

 $ makepkg     

After successfully building the package, you can install the package using pacman.

 
 # pacman -U motsognir-1.0.13-1-any.pkg.tar.zst

Once the package has been installed, like any other server, it must be configured and enabled. Fortunately, the config file is quite straight forward. You will have to create the config file with your favorite text editor.

 # vim /etc/motsognir.conf

I have provided an extremely simple configuration file below.

 GopherHostname=<domain.tdl>
 GohperPort=70
 GopherRoot=</path/to/gopher/>

This should be enough to get you started. Before you run the server, make sure that the root directory exists (generally I put my websites in /srv/ or /var/www/).

Finally we can enable the server.

 # systemctl start motsognir.service

If you make any changes to the configuration file, be sure to reload the server. There is also a detailed manual available on the GitHub repository. It can be referenced here.

Gopher basics

Now that you have a server, let's create a basic Gopher site! At its core, a simple Gopher site is a collection of directories and text files. You can put a special file called a gophermap in any directory and any Gopher will treat it like a menu that allows users to open files, navigate subdirectories, or download and open non-textual data (audio, video, images, etc.).

 srv/
 |--gopher/
    |--gophermap
    |--about.txt
    |--blog/
       |--gophermap
       |--post1.txt
       |--post2.txt

Gophermaps have a special syntax. It's kinda wonky, but it's not too bad once you get used to it. The following table is lifted from the Motsognir manual.

Code Data Type
i Text message/descriptor
0 A text file
1 A directory/menu item
I An image file
g A gif file

The following is an example gophermap with an about us page and a sub-directory containing some blog posts. All entries are tab delimited. I have indicated these below with <tab>. If you use spaces, the file will not be parsed correctly.

 iSome Gopher Site!
 i
 0About<tab>/about.txt
 1Blog<tab>/blog 
 i
 iThanks for visting :)

In a text based browser like Lynx or cgo, the above gophermap will be displayed as follows:

     Some Gopher Site!
 (FILE) About
 (DIR)  Blog
     Thanks for visting :)

That's all you really need to know to get started! There's a lot of fun sites out there, so have fun!

Resources


  1. Motsognir Manual.
  2. Floodgap