gopher-setup.org
1	* Setting up a Gopher Server
2
3 Hey folks! In this post I'm going to talk a bit about setting
4 up my Gopher server and some of the choices I made in doing so.
5
6 I hope this is helpful to anyone who stumbles onto this article!
7
8 Disclaimer: I'm only a few weeks into learning about Gopher
9 and the so-called "indie-net", so this article may not
10 represent the better part of community knowledge, or
11 "best practices".
12
13 * Basics
14
15 I'll just rattle these off quickly so that we don't need to spend
16 too much time on them:
17
18 - Server: Ubuntu VPS
19 - Gopher Server: Motsognir
20
21 I won't cover the basics of setting up Motsognir or a basic Gopher
22 map, as others have already done a great job covering these topics.
23
24 Checkout the following WWW links on the topic:
25 https://gopher.zone/
26 https://usermanual.wiki/Document/manual.488145643/help
27
28 * CGI
29
30 Because Gopher is a pretty simple protocol spec, I wanted to
31 not serve static gopher maps and instead implement everything
32 as a CGI script. This allows me to be pretty flexible with
33 the formatting and configuration of the site:
34
35 - Can provide a 'plain' non ANSI escape sequence cluttered
36 version of the site for users who prefer the minimalism
37 of uniform text/chars
38 - Can provide interesting tidbits like Last Modification
39 date of the site and # of uniq visitors
40 - Silly stuff like intermediate http requests (server side)
41 to my git server so that I can serve all of my git website
42 natively in Gopher
43
44 The CGI source is actually available to view live, see:
45 gopher://chate.io/0/foobar.txt
46
47 Note: The Gopher server Gophernicus actually offers what I
48 think is an even cooler way of doing this, with what it calls
49 moles. Check it out: https://github.com/gophernicus/gophernicus
50
51 I may move over to gophernicus at some point, but for now
52 I'm enjoying the ease of use of Motsognir.
53
54 On that topic, to get all the CGI stuff working correctly
55 I had to set the following values in the Motsognir config
56 file. The config file is awesome, and well documented, but
57 as a newcomer to the protocol it was somewhat confusing
58 to get it configured right, so I've provided the following:
59
60 GopherCgiSupport=1
61 SubGophermaps=1
62 DefaultGophermap=
63
64 I'd encourage reading the comments for each of these settings
65 for a clearer understanding of what they're doing, but I leave
66 this exercise to the reader.
67
68 ** Footguns and Hangups
69
70 A few things I learned trying to always dynamically
71 generate my gophermap:
72
73 - Clients can be finnicky and the protocl spec seems
74 to be not super well agreed upon by client
75 implimenters
76 - Some clients will not correctly parse info
77 lines if there is a " " after the i
78 - Some clients will seemingly ignore info lines
79 - Some clients don't mind if you don't have a "."
80 char at the EOF, others seem to really care
81 - Apparently the "." at EOF is part of the spec,
82 so it really should be there
83 - Some clients will automagically parse out any ANSI
84 escape sequnces, others will interpret them correctly,
85 and others will barf them to the screen literally
86 - To my knowledge there is nothing in the spec for
87 handling this, so client implementers can't be blamed
88 - Some gopher servers will helpfully auto fill lines in a
89 map that don't contain <TAB>$host<$TAB>$port. I learned
90 that motsognir will do this on a statically served map,
91 but (in hindsight, obviously), not a dynamically
92 generated one, so make sure you're filling that out
93
94 ** Helpful Patterns
95
96 A few helpful patterns I've employed while writing my CGI
97 scripts:
98
99 - Establish an interface for printing your gopher map. I use
100 a function that takes 3 args: $gopher_menu_type, $string,
101 $rest.
102
103 The idea being that you call the function this way:
104 g_print("1","Some Dir","\t$path\t$hostname\t$port");
105
106 This function will then, depending on what/if it gets
107 a CGI query parameter, will either randomly colorize
108 the output or not, allowing the site to be easily rendered
109 one way or another.
110
111 - As with stuff on WWW, make sure your CGI scripts are
112 executing quickly, otherwise the client will be left waiting