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 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 To install execute:
45 make install
47 If you have trouble installing LibreSSL or libretls, as they aren't
48 available as package on various Linux distribution, you can use Docker
49 to build a `gmid` image with:
51 docker build -t gmid .
53 and then run it with something along the lines of
55 docker run --rm -it -p 1965:1965 \
56 -v /path/to/cert.pem:...:ro \
57 -v /path/to/key.pem:...:ro \
58 -v /path/to/docs:/var/gemini \
59 gmid -f -d /var/gemini -K ... -C ...
61 ellipses used for brevity.
64 ## Architecture/Security considerations
66 gmid is composed by two processes: a listener and an executor. The
67 listener process is the only one that needs internet access and is
68 sandboxed. When a CGI script needs to be executed, the executor
69 (outside of the sandbox) sets up a pipe and gives one end to the
70 listener, while the other is bound to the CGI script standard output.
71 This way, is still possible to execute CGI scripts without restriction
72 even in the presence of a sandbox.
74 On OpenBSD, the listener process runs with the `stdio recvfd rpath
75 inet` pledges and has `unveil(2)`ed only the directories that it
76 serves; the executor has `stdio sendfd proc exec` as pledges.
78 On FreeBSD, the executor process is sandboxed with `capsicum(4)`.
80 On Linux, a `seccomp(2)` filter is installed to allow only certain
81 syscalls, see [sandbox.c](sandbox.c) for more information on the BPF
82 program.
84 In any case, you are invited to run gmid inside some sort of
85 container/jail.