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 - automatic certificate generation (in config-less mode)
34 - CGI scripts
35 - (very) low memory footprint
36 - small codebase, easily hackable
37 - virtual hosts
38 - per-location rules
39 - optional directory listings
40 - configurable mime types
41 - sandboxed by default on OpenBSD, Linux and FreeBSD
42 - chroot support
45 ## Drawbacks
47 - not suited for very busy hosts. If you receive an high number of
48 connection per-second you'd probably want to run multiple gmid
49 instances behind relayd/haproxy or a different server.
52 ## Internationalisation (IRIs, UNICODE, punycode, all that stuff)
54 Even thought the current Gemini specification doesn't mention anything
55 in this regard, I do think these are important things, so I tried to
56 implement them in the most user-friendly way I could think of.
58 For starters, gmid has full support for IRI (RFC3987 --
59 Internationalized Resource Identifiers). IRIs are a superset of URI,
60 so there aren't incompatibilities with URI-only clients.
62 There is full support also for punycode. In theory, the users doesn't
63 even need to know that punycode is a thing. The hostname in the
64 configuration file can (and must be) written with proper UNICODE, gmid
65 will do the rest.
67 The only missing piece is UNICODE normalisation. gmid doesn't
68 do that (yet).
71 ## Building
73 gmid depends on a POSIX libc, OpenSSL/LibreSSL and libtls (provided
74 either by LibreSSL or libretls). At build time, flex and yacc (or GNU
75 bison) are also needed.
77 The build is as simple as
79 make
81 If the configure scripts fails to pick up something, please open an
82 issue or notify me via email.
84 To install execute:
86 make install
88 If you have trouble installing LibreSSL or libretls, as they aren't
89 available as package on various Linux distribution, you can use Docker
90 to build a `gmid` image with:
92 docker build -t gmid .
94 and then run it with something along the lines of
96 docker run --rm -it -p 1965:1965 \
97 -v /path/to/gmid.conf:...:ro \
98 -v /path/to/docs:/var/gemini \
99 gmid -c .../gmid.conf
101 ellipses for brevity.
103 ### Local libretls
105 This is **NOT** recommended, please try to port LibreSSL/LibreTLS to
106 your distribution of choice or use docker instead.
108 However, it's possible to link `gmid` to locally-installed libtls
109 quite easily. (It's how I test gmid on Fedora, for instance)
111 Let's say you have compiled and installed libretls in `$LIBRETLS`,
112 then you can build `gmid` with
114 ./configure CFLAGS="-I$LIBRETLS/include" \
115 LDFLAGS="$LIBRETLS/lib/libtls.a -lssl -lcrypto -lpthread"
116 make
118 ### Testing
120 Execute
122 make regress
124 to start the suite. Keep in mind that the suite will create files
125 inside the `regress` directory and bind the 10965 port.
128 ## Architecture/Security considerations
130 gmid is composed by two processes: a listener and an executor. The
131 listener process is the only one that needs internet access and is
132 sandboxed. When a CGI script needs to be executed, the executor
133 (outside of the sandbox) sets up a pipe and gives one end to the
134 listener, while the other is bound to the CGI script standard output.
135 This way, is still possible to execute CGI scripts without
136 restrictions even in the presence of a sandbox.
138 On OpenBSD, the listener process runs with the `stdio recvfd rpath
139 inet` pledges, the executor has `stdio sendfd proc exec` as pledges;
140 both have unveiled only the served directories.
142 On FreeBSD, the executor process is sandboxed with `capsicum(4)`.
144 On Linux, a `seccomp(2)` filter is installed to allow only certain
145 syscalls, see [sandbox.c](sandbox.c) for more information on the BPF
146 program.
148 In any case, you are invited to run gmid inside some sort of
149 container/jail/chroot.