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 If the configure scripts fails to pick up something, please open an
44 issue or notify me via email.
46 To install execute:
48 make install
50 If you have trouble installing LibreSSL or libretls, as they aren't
51 available as package on various Linux distribution, you can use Docker
52 to build a `gmid` image with:
54 docker build -t gmid .
56 and then run it with something along the lines of
58 docker run --rm -it -p 1965:1965 \
59 -v /path/to/cert.pem:...:ro \
60 -v /path/to/key.pem:...:ro \
61 -v /path/to/docs:/var/gemini \
62 gmid -f -d /var/gemini -K ... -C ...
64 ellipses used for brevity.
66 ### Local libretls
68 This is **NOT** recommended, please try to port LibreSSL/LibreTLS to
69 your distribution of choice or use docker instead.
71 However, it's possible to link `gmid` to locally-installed libtls
72 quite easily. (It's how I test gmid on Fedora, for instance)
74 Let's say you have compiled and installed libretls in `$LIBRETLS`,
75 then you can build `gmid` with
77 ./configure CFLAGS="-I$LIBRETLS/include" \
78 LDFLAGS="$LIBRETLS/lib/libtls.a -lssl -lcrypto"
79 make
81 (Fedora requires also `-lpthread` for some reason)
84 ### Testing
86 The regression suite requires python3 at the moment. Execute
88 make regress
90 to start the suite. Keep in mind that the suit will create files
91 inside the `regress` directory and bind the 10965 port.
94 ## Architecture/Security considerations
96 gmid is composed by two processes: a listener and an executor. The
97 listener process is the only one that needs internet access and is
98 sandboxed. When a CGI script needs to be executed, the executor
99 (outside of the sandbox) sets up a pipe and gives one end to the
100 listener, while the other is bound to the CGI script standard output.
101 This way, is still possible to execute CGI scripts without restriction
102 even in the presence of a sandbox.
104 On OpenBSD, the listener process runs with the `stdio recvfd rpath
105 inet` pledges and has `unveil(2)`ed only the directories that it
106 serves; the executor has `stdio sendfd proc exec` as pledges.
108 On FreeBSD, the executor process is sandboxed with `capsicum(4)`.
110 On Linux, a `seccomp(2)` filter is installed to allow only certain
111 syscalls, see [sandbox.c](sandbox.c) for more information on the BPF
112 program.
114 In any case, you are invited to run gmid inside some sort of
115 container/jail.