4 **gmid** - dead simple zero configuration gemini server
10 \[**-c** *cert.pem*]
12 \[**-k** *key.pem*]
13 \[**-l** *logfile*]
14 \[**-x** *cgi-bin*]
19 is a very simple and minimal gemini server that can serve static files
20 and execute CGI scripts.
23 will strip any sequence of
27 in the requests made by clients and will refuse to follow symlinks.
33 are used to ensure that
35 dosen't do anything else than read files from the given directory,
36 accept network connections and, optionally, execute CGI scripts.
38 It should be noted that
40 is very simple in its implementation, and so it may not be appropriate
41 for serving sites with lots of users.
42 After all, the code is single threaded and use a single process,
43 although it can handle multiple requests concurrently.
45 If a user request path is a directory,
49 file inside that directory.
51 The options are as follows:
55 > The certificate to use, by default is
60 > The root directory to serve.
62 > won't serve any file that is outside that directory.
68 > Print the usage and exit.
72 > The key for the certificate, by default is
77 > log to the given file instead of the standard error.
81 > Enable execution of CGI scripts inside the given directory (relative
82 > to the document root.) Cannot be provided more than once.
86 When CGI scripts are enabled for a directory, a request for an
87 executable file will execute it and fed its output to the client.
89 The CGI scripts will inherit the environment from
91 with these additional variables set:
103 > The (public) path to the script.
107 > The full path to the executable.
111 > The user request (without the query parameters.)
115 > The request relative to the script.
119 > The query parameters.
123 > The remote IP address.
127 > The root directory being served, the one provided with the
132 Let's say you have a script in
134 and the user request is
135 */cgi-bin/script/foo/bar?quux*.
142 *$DOCUMENT\_ROOT/cgi-bin/script*,
145 */cgi-bin/script/foo/bar*,
155 To quickly getting started
157 $ # generate a cert and a key
158 $ openssl req -x509 -newkey rsa:4096 -keyout key.pem \
159 -out cert.pem -days 365 -nodes
161 $ cat <<EOF > docs/index.gmi
165 $ gmid -c cert.pem -k key.pem -d docs
167 Now you can visit gemini://localhost/ with your preferred gemini
170 To add some CGI scripts, assuming a setup similar to the previous
174 $ cat <<EOF > docs/cgi-bin/hello-world
176 printf "20 text/plain\r\n"
181 Note that the argument to the
187 since it's relative to the document root.
191 * it doesn't support virtual hosts: the host part of the request URL is
194 * it doesn't fork in the background or anything like that.