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 - dual stack: can serve over both IPv4 and IPv6
32 - CGI scripts
33 - (very) low memory footprint
34 - small codebase, easily hackable
35 - virtual hosts
36 - rules per-location
37 - directory listings
38 - mime types configurable
39 - index file configurable
40 - sandboxed by default on OpenBSD, Linux and FreeBSD
41 - chroot support
44 ## Drawbacks
46 - not suited for very busy hosts. If you receive an high number of
47 connection per-second you'd probably want to run multiple gmid
48 instances behind relayd/haproxy or a different server.
50 ## Building
52 gmid depends on a POSIX libc, OpenSSL/LibreSSL and libtls (provided
53 either by LibreSSL or libretls). At build time, flex and yacc (or GNU
54 bison) are also needed.
56 The build is as simple as
58 make
60 If the configure scripts fails to pick up something, please open an
61 issue or notify me via email.
63 To install execute:
65 make install
67 If you have trouble installing LibreSSL or libretls, as they aren't
68 available as package on various Linux distribution, you can use Docker
69 to build a `gmid` image with:
71 docker build -t gmid .
73 and then run it with something along the lines of
75 docker run --rm -it -p 1965:1965 \
76 -v /path/to/gmid.conf:...:ro \
77 -v /path/to/docs:/var/gemini \
78 gmid -c .../gmid.conf
80 ellipses for brevity.
82 ### Local libretls
84 This is **NOT** recommended, please try to port LibreSSL/LibreTLS to
85 your distribution of choice or use docker instead.
87 However, it's possible to link `gmid` to locally-installed libtls
88 quite easily. (It's how I test gmid on Fedora, for instance)
90 Let's say you have compiled and installed libretls in `$LIBRETLS`,
91 then you can build `gmid` with
93 ./configure CFLAGS="-I$LIBRETLS/include" \
94 LDFLAGS="$LIBRETLS/lib/libtls.a -lssl -lcrypto -lpthread"
95 make
97 ### Testing
99 Execute
101 make regress
103 to start the suite. Keep in mind that the suite will create files
104 inside the `regress` directory and bind the 10965 port.
107 ## Architecture/Security considerations
109 gmid is composed by two processes: a listener and an executor. The
110 listener process is the only one that needs internet access and is
111 sandboxed. When a CGI script needs to be executed, the executor
112 (outside of the sandbox) sets up a pipe and gives one end to the
113 listener, while the other is bound to the CGI script standard output.
114 This way, is still possible to execute CGI scripts without
115 restrictions even in the presence of a sandbox.
117 On OpenBSD, the listener process runs with the `stdio recvfd rpath
118 inet` pledges, the executor has `stdio sendfd proc exec` as pledges;
119 both have unveiled only the served directories.
121 On FreeBSD, the executor process is sandboxed with `capsicum(4)`.
123 On Linux, a `seccomp(2)` filter is installed to allow only certain
124 syscalls, see [sandbox.c](sandbox.c) for more information on the BPF
125 program.
127 In any case, you are invited to run gmid inside some sort of
128 container/jail/chroot.