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 gmid 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.
16 ## Features
18 - IRI support (RFC3987)
19 - dual stack: can serve over both IPv4 and IPv6
20 - CGI scripts
21 - (very) low memory footprint
22 - small codebase, easily hackable
23 - virtual hosts
24 - sandboxed by default on OpenBSD, Linux and FreeBSD
27 ## Drawbacks
29 - not suited for very busy hosts. If you receive an high number of
30 connection per-second you'd probably want to run multiple gmid
31 instances behind relayd/haproxy or a different server.
33 ## Building
35 gmid depends on a POSIX libc and libtls (provided either by LibreSSL
36 or libretls). At build time, flex and yacc (or GNU bison) are also
37 needed.
39 The build is as simple as
41 make
43 or
45 make static
47 to enjoy your ~2.3M statically-linked gmid.
49 To install execute:
51 make install
53 If you have trouble installing LibreSSL or libretls, as they aren't
54 available as package on various Linux distribution, you can use Docker
55 to build a `gmid` image with:
57 docker build -t gmid .
59 and then run it with something along the lines of
61 docker run --rm -it -p 1965:1965 \
62 -v /path/to/cert.pem:...:ro \
63 -v /path/to/key.pem:...:ro \
64 -v /path/to/docs:/var/gemini \
65 gmid -f -d /var/gemini -K ... -C ...
67 ellipses used for brevity.
70 ## Architecture/Security considerations
72 gmid is composed by two processes: a listener and an executor. The
73 listener process is the only one that needs internet access and is
74 sandboxed. When a CGI script needs to be executed, the executor
75 (outside of the sandbox) sets up a pipe and gives one end to the
76 listener, while the other is bound to the CGI script standard output.
77 This way, is still possible to execute CGI scripts without restriction
78 even if the presence of a sandbox.
80 On OpenBSD, the listener process runs with the `stdio recvfd rpath
81 inet` pledges and has `unveil(2)`ed only the directories that it
82 serves; the executor has `stdio sendfd proc exec` as pledges.
84 On FreeBSD, the executor process is sandboxed with `capsicum(4)`.
86 On Linux, a `seccomp(2)` filter is installed to allow only certain
87 syscalls, see [sandbox.c](sandbox.c) for more information on the BPF
88 program.
90 In any case, you are invited to run gmid inside some sort of
91 container/jail.