4 **gmid** - dead simple zero configuration gemini server
10 \[**-c** *cert.pem*]
12 \[**-k** *key.pem*]
13 \[**-l** *logfile*]
15 \[**-x** *cgi-bin*]
20 is a very simple and minimal gemini server that can serve static files
21 and execute CGI scripts.
24 will strip any sequence of
28 in the requests made by clients and will refuse to follow symlinks.
34 are used to ensure that
36 dosen't do anything else than read files from the given directory,
37 accept network connections and, optionally, execute CGI scripts.
39 It should be noted that
41 is very simple in its implementation, and so it may not be appropriate
42 for serving sites with lots of users.
43 After all, the code is single threaded and use a single process,
44 although it can handle multiple requests concurrently.
46 If a user request path is a directory,
50 file inside that directory.
52 The options are as follows:
56 > The certificate to use, by default is
61 > The root directory to serve.
63 > won't serve any file that is outside that directory.
69 > Print the usage and exit.
73 > The key for the certificate, by default is
78 > log to the given file instead of the standard error.
82 > The port to bind to, by default 1965.
86 > Enable execution of CGI scripts inside the given directory (relative
87 > to the document root.) Cannot be provided more than once.
91 When CGI scripts are enabled for a directory, a request for an
92 executable file will execute it and fed its output to the client.
94 The CGI scripts will inherit the environment from
96 with these additional variables set:
108 > The (public) path to the script.
112 > The full path to the executable.
116 > The user request (without the query parameters.)
120 > The request relative to the script.
124 > The query parameters.
128 > The remote IP address.
132 > The root directory being served, the one provided with the
137 Let's say you have a script in
139 and the user request is
140 */cgi-bin/script/foo/bar?quux*.
147 *$DOCUMENT\_ROOT/cgi-bin/script*,
150 */cgi-bin/script/foo/bar*,
160 To quickly getting started
162 $ # generate a cert and a key
163 $ openssl req -x509 -newkey rsa:4096 -keyout key.pem \
164 -out cert.pem -days 365 -nodes
166 $ cat <<EOF > docs/index.gmi
170 $ gmid -c cert.pem -k key.pem -d docs
172 Now you can visit gemini://localhost/ with your preferred gemini
175 To add some CGI scripts, assuming a setup similar to the previous
179 $ cat <<EOF > docs/cgi-bin/hello-world
181 printf "20 text/plain\r\n"
186 Note that the argument to the
192 since it's relative to the document root.
196 * it doesn't support virtual hosts: the host part of the request URL is
199 * it doesn't fork in the background or anything like that.