Blob


1 # gmid
3 **the `master` branch is WIP: it's what gmid 2.0 will be, with breaking
4 changes et al. Please use the latest release from the 1.8 branch for a
5 stable and documented experience, thank you.**
7 gmid is a fast Gemini server written with security in mind. I
8 initially wrote it to serve static files, but it has grown into a
9 featureful server.
12 ## Features
14 (random order)
16 - sandboxed by default on OpenBSD, Linux and FreeBSD
17 - reconfiguration: reload the running configuration without
18 interruption
19 - automatic redirect/error pages (see `block return`)
20 - IRI support (RFC3987)
21 - automatic certificate generation for config-less mode
22 - reverse proxying
23 - FastCGI support
24 - virtual hosts
25 - location rules
26 - event-based asynchronous I/O model
27 - low memory footprint
28 - small codebase, easily hackable
31 ## Internationalisation (IRIs, UNICODE, punycode, all that stuff)
33 Even thought the current Gemini specification doesn't mention anything
34 in this regard, I do think these are important things and so I tried
35 to implement them in the most user-friendly way I could think of.
37 For starters, gmid has full support for IRI (RFC3987 —
38 Internationalized Resource Identifiers). IRIs are a superset of URIs,
39 so there aren't incompatibilities with URI-only clients.
41 There is full support also for punycode. In theory, the user doesn't
42 even need to know that punycode is a thing. The hostname in the
43 configuration file can (and must be) in the decoded form (e.g. `naïve`
44 and not `xn--nave-6pa`), gmid will do the rest.
46 The only missing piece is UNICODE normalisation of the IRI path: gmid
47 doesn't do that (yet).
50 ## Configuration
52 gmid has a rich configuration file, heavily inspired by OpenBSD'
53 httpd, with every detail carefully documented in the manpage. Here's
54 a minimal example of a config file:
56 ```conf
57 server "example.com" {
58 cert "/path/to/cert.pem"
59 key "/path/to/key.pem"
60 root "/var/gemini/example.com"
61 }
62 ```
64 and a slightly more complex one
66 ```conf
67 ipv6 on # enable ipv6
69 # define a macro
70 cert_root = "/path/to/keys"
72 server "example.com" {
73 alias "foobar.com"
75 cert $cert_root "/example.com.crt"
76 key $cert_root "/example.com.pem"
77 root "/var/gemini/example.com"
79 # lang for text/gemini files
80 lang "en"
82 # only for locations that matches /files/*
83 location "/files/*" {
84 # generate directory listings
85 auto index on
86 }
88 location "/repo/*" {
89 # change the index file name
90 index "README.gmi"
91 lang "it"
92 }
93 }
94 ```
97 ## Building
99 gmid depends on libevent2, OpenSSL/LibreSSL and libtls (provided
100 either by LibreSSL or libretls). At build time, yacc (or GNU bison)
101 is also needed.
103 The build is as simple as
105 ./configure
106 make
108 or `make static` to build a statically-linked executable.
110 If the configure scripts fails to pick up something, please open an
111 issue or notify me via email.
113 To install execute:
115 make install
117 Please keep in mind that the master branch, from time to time, may be
118 accidentally broken on some platforms. gmid is developed primarily on
119 OpenBSD/amd64 and commits on the master branch don't get always tested
120 in other OSes. Before tagging a release however, a comprehensive
121 testing on various platform is done to ensure that everything is
122 working as intended.
125 ### Testing
127 Execute
129 make regress
131 to start the suite. Keep in mind that the regression tests needs to
132 create files inside the `regress` directory and bind the 10965 port.
135 ## Contributing
137 Any form of contribution is welcome, not only patches or bug reports.
138 If you have a sample configuration for some specific use-case, a
139 script or anything that could be useful to others, consider adding it
140 to the `contrib` directory.
143 ## Architecture/Security considerations
145 **outdated: revisit for gmid 2.0**
148 gmid is composed by four processes: the parent process, the logger,
149 the listener and the executor. The parent process is the only one
150 that doesn't drop privileges, but all it does is to wait for a SIGHUP
151 to reload the configuration and spawn a new generation of children
152 process. The logger process gathers the logs and prints 'em to
153 stderr or syslog (for the time being.) The listener process is the
154 only one that needs internet access and is sandboxed by default. The
155 executor process exists only to fork and execute CGI scripts, and
156 optionally to connect to FastCGI applications.
158 On OpenBSD the processes are all `pledge(2)`d and `unveil(2)`ed.
160 On FreeBSD, the listener and logger process are sandboxed with `capsicum(4)`.
162 On Linux, a `seccomp(2)` filter is installed in the listener to allow
163 only certain syscalls, see [sandbox.c](sandbox.c) for more information
164 about the BPF program. If available, landlock is used to limit the
165 portion of the file system gmid can access (requires linux 5.13+.)
167 In any case, it's advisable to run gmid inside some sort of
168 container/jail/chroot.