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
25 - chroot support
28 ## Drawbacks
30 - not suited for very busy hosts. If you receive an high number of
31 connection per-second you'd probably want to run multiple gmid
32 instances behind relayd/haproxy or a different server.
34 ## Building
36 gmid depends on a POSIX libc and libtls (provided either by LibreSSL
37 or libretls). At build time, flex and yacc (or GNU bison) are also
38 needed.
40 The build is as simple as
42 make
44 If the configure scripts fails to pick up something, please open an
45 issue or notify me via email.
47 To install execute:
49 make install
51 If you have trouble installing LibreSSL or libretls, as they aren't
52 available as package on various Linux distribution, you can use Docker
53 to build a `gmid` image with:
55 docker build -t gmid .
57 and then run it with something along the lines of
59 docker run --rm -it -p 1965:1965 \
60 -v /path/to/cert.pem:...:ro \
61 -v /path/to/key.pem:...:ro \
62 -v /path/to/docs:/var/gemini \
63 gmid -f -d /var/gemini -K ... -C ...
65 ellipses used for brevity.
67 ### Local libretls
69 This is **NOT** recommended, please try to port LibreSSL/LibreTLS to
70 your distribution of choice or use docker instead.
72 However, it's possible to link `gmid` to locally-installed libtls
73 quite easily. (It's how I test gmid on Fedora, for instance)
75 Let's say you have compiled and installed libretls in `$LIBRETLS`,
76 then you can build `gmid` with
78 ./configure CFLAGS="-I$LIBRETLS/include" \
79 LDFLAGS="$LIBRETLS/lib/libtls.a -lssl -lcrypto -lpthread"
80 make
82 ### Testing
84 Execute
86 make regress
88 to start the suite. Keep in mind that the suite will create files
89 inside the `regress` directory and bind the 10965 port.
92 ## Architecture/Security considerations
94 gmid is composed by two processes: a listener and an executor. The
95 listener process is the only one that needs internet access and is
96 sandboxed. When a CGI script needs to be executed, the executor
97 (outside of the sandbox) sets up a pipe and gives one end to the
98 listener, while the other is bound to the CGI script standard output.
99 This way, is still possible to execute CGI scripts without restriction
100 even in the presence of a sandbox.
102 On OpenBSD, the listener process runs with the `stdio recvfd rpath
103 inet` pledges and has `unveil(2)`ed only the directories that it
104 serves; the executor has `stdio sendfd proc exec` as pledges.
106 On FreeBSD, the executor process is sandboxed with `capsicum(4)`.
108 On Linux, a `seccomp(2)` filter is installed to allow only certain
109 syscalls, see [sandbox.c](sandbox.c) for more information on the BPF
110 program.
112 In any case, you are invited to run gmid inside some sort of
113 container/jail/chroot.