Blob


1 # gmid
3 > dead simple, zero configuration Gemini server
5 gmid is a simple and minimal Gemini server. It can run without
6 configuration, so it's well suited for local development, but at the
7 same time has a configuration file flexible enough to meet the
8 requirements of most capsules.
10 It was initially written to serve static files, but can also
11 optionally execute CGI scripts. It was also written with security in
12 mind: on Linux, FreeBSD and OpenBSD is sandboxed via `seccomp(2)`,
13 `capsicum(4)`and `pledge(2)`+`unveil(2)` respectively.
15 gmid can be used from the command line to serve local directories
17 # serve the directory docs
18 gmid docs
20 or you can pass a configuration file and have access to all the
21 features
23 gmid -c /etc/gmid.conf
25 Please consult the [manpage](gmid.1) for more information.
28 ## Features
30 - IRI support (RFC3987)
31 - punycode support
32 - dual stack: can serve over both IPv4 and IPv6
33 - CGI scripts
34 - (very) low memory footprint
35 - small codebase, easily hackable
36 - virtual hosts
37 - per-location rules
38 - optional directory listings
39 - configurable mime types
40 - sandboxed by default on OpenBSD, Linux and FreeBSD
41 - chroot support
44 ## Drawbacks
46 - not suited for very busy hosts. If you receive an high number of
47 connection per-second you'd probably want to run multiple gmid
48 instances behind relayd/haproxy or a different server.
51 ## Internationalisation (IRIs, UNICODE, punycode, all that stuff)
53 Even thought the current Gemini specification doesn't mention anything
54 in this regard, I do think these are important things, so I tried to
55 implement them in the most user-friendly way I could think of.
57 For starters, gmid has full support for IRI (RFC3987 --
58 Internationalized Resource Identifiers). IRIs are a superset of URI,
59 so there aren't incompatibilities with URI-only clients.
61 There is full support also for punycode. In theory, the users doesn't
62 even need to know that punycode is a thing. The hostname in the
63 configuration file can (and must be) written with proper UNICODE, gmid
64 will do the rest.
66 The only missing piece is UNICODE normalisation. gmid doesn't
67 do that (yet).
70 ## Building
72 gmid depends on a POSIX libc, OpenSSL/LibreSSL and libtls (provided
73 either by LibreSSL or libretls). At build time, flex and yacc (or GNU
74 bison) are also needed.
76 The build is as simple as
78 make
80 If the configure scripts fails to pick up something, please open an
81 issue or notify me via email.
83 To install execute:
85 make install
87 If you have trouble installing LibreSSL or libretls, as they aren't
88 available as package on various Linux distribution, you can use Docker
89 to build a `gmid` image with:
91 docker build -t gmid .
93 and then run it with something along the lines of
95 docker run --rm -it -p 1965:1965 \
96 -v /path/to/gmid.conf:...:ro \
97 -v /path/to/docs:/var/gemini \
98 gmid -c .../gmid.conf
100 ellipses for brevity.
102 ### Local libretls
104 This is **NOT** recommended, please try to port LibreSSL/LibreTLS to
105 your distribution of choice or use docker instead.
107 However, it's possible to link `gmid` to locally-installed libtls
108 quite easily. (It's how I test gmid on Fedora, for instance)
110 Let's say you have compiled and installed libretls in `$LIBRETLS`,
111 then you can build `gmid` with
113 ./configure CFLAGS="-I$LIBRETLS/include" \
114 LDFLAGS="$LIBRETLS/lib/libtls.a -lssl -lcrypto -lpthread"
115 make
117 ### Testing
119 Execute
121 make regress
123 to start the suite. Keep in mind that the suite will create files
124 inside the `regress` directory and bind the 10965 port.
127 ## Architecture/Security considerations
129 gmid is composed by two processes: a listener and an executor. The
130 listener process is the only one that needs internet access and is
131 sandboxed. When a CGI script needs to be executed, the executor
132 (outside of the sandbox) sets up a pipe and gives one end to the
133 listener, while the other is bound to the CGI script standard output.
134 This way, is still possible to execute CGI scripts without
135 restrictions even in the presence of a sandbox.
137 On OpenBSD, the listener process runs with the `stdio recvfd rpath
138 inet` pledges, the executor has `stdio sendfd proc exec` as pledges;
139 both have unveiled only the served directories.
141 On FreeBSD, the executor process is sandboxed with `capsicum(4)`.
143 On Linux, a `seccomp(2)` filter is installed to allow only certain
144 syscalls, see [sandbox.c](sandbox.c) for more information on the BPF
145 program.
147 In any case, you are invited to run gmid inside some sort of
148 container/jail/chroot.