4 **gmid** - dead simple zero configuration gemini server
10 \[**-c** *cert.pem*]
12 \[**-k** *key.pem*]
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 clients at the same time.
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 > stays and log in the foreground, do not daemonize the process.
72 > Print the usage and exit.
76 > The key for the certificate, by default is
81 > The port to bind to, by default 1965.
85 > Enable execution of CGI scripts inside the given directory (relative
86 > to the document root.) Cannot be provided more than once.
90 When CGI scripts are enabled for a directory, a request for an
91 executable file will execute it and fed its output to the client.
93 The CGI scripts will inherit the environment from
95 with these additional variables set:
107 > The (public) path to the script.
111 > The full path to the executable.
115 > The user request (without the query parameters.)
119 > The request relative to the script.
123 > The query parameters.
127 > The remote IP address.
131 > The remote IP address.
135 > The root directory being served, the one provided with the
142 > The string "Certificate" if the client used a certificate, otherwise unset.
146 > The subject of the client certificate if provided, otherwise unset.
150 > The is the issuer of the client certificate if provided, otherwise unset.
154 > The hash of the client certificate if provided, otherwise unset.
155 > The format is "ALGO:HASH".
157 Let's say you have a script in
159 and the user request is
160 */cgi-bin/script/foo/bar?quux*.
167 *$DOCUMENT\_ROOT/cgi-bin/script*,
170 */cgi-bin/script/foo/bar*,
180 To quickly getting started
182 $ # generate a cert and a key
183 $ openssl req -x509 -newkey rsa:4096 -keyout key.pem \
184 -out cert.pem -days 365 -nodes
186 $ cat <<EOF > docs/index.gmi
190 $ gmid -c cert.pem -k key.pem -d docs
192 Now you can visit gemini://localhost/ with your preferred gemini
195 To add some CGI scripts, assuming a setup similar to the previous
199 $ cat <<EOF > docs/cgi-bin/hello-world
201 printf "20 text/plain\r\n"
206 Note that the argument to the
212 since it's relative to the document root.
216 * it doesn't support virtual hosts: the host part of the request URL is