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 - CGI and 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 # execute CGI scripts in /cgi/
79 cgi "/cgi/*"
81 # only for locations that matches /files/*
82 location "/files/*" {
83 # generate directory listings
84 auto index on
85 }
87 location "/repo/*" {
88 # change the index file name
89 index "README.gmi"
90 lang "it"
91 }
92 }
93 ```
96 ## Building
98 gmid depends on libevent2, OpenSSL/LibreSSL and libtls (provided
99 either by LibreSSL or libretls). At build time, yacc (or GNU bison)
100 is also needed.
102 The build is as simple as
104 ./configure
105 make
107 or `make static` to build a statically-linked executable.
109 If the configure scripts fails to pick up something, please open an
110 issue or notify me via email.
112 To install execute:
114 make install
116 Please keep in mind that the master branch, from time to time, may be
117 accidentally broken on some platforms. gmid is developed primarily on
118 OpenBSD/amd64 and commits on the master branch don't get always tested
119 in other OSes. Before tagging a release however, a comprehensive
120 testing on various platform is done to ensure that everything is
121 working as intended.
124 ### Testing
126 Execute
128 make regress
130 to start the suite. Keep in mind that the regression tests needs to
131 create files inside the `regress` directory and bind the 10965 port.
134 ## Contributing
136 Any form of contribution is welcome, not only patches or bug reports.
137 If you have a sample configuration for some specific use-case, a
138 script or anything that could be useful to others, consider adding it
139 to the `contrib` directory.
142 ## Architecture/Security considerations
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.