Blob


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