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, so it's impossible to serve content
30 directory by mistake, and will also refuse to follow symlinks.
36 are used to ensure that
38 dosen't do anything else than read files from the given directory,
39 accept network connections and, optionally, execute CGI scripts.
41 It should be noted that
43 is very simple in its implementation, and so it may not be appropriate
44 for serving sites with lots of users.
45 After all, the code is single threaded and use a single process,
46 although it can handle multiple requests concurrently.
48 If a user request path is a directory,
52 file inside that directory.
53 If not found, it will return an error 51 (not found) to the user.
55 The options are as follows:
59 > The certificate to use, by default is
64 > The root directory to serve.
66 > won't serve any file that is outside that directory, by default
71 > Print the usage and exit.
75 > The key for the certificate, by default is
80 > log to the given file instead of the standard error.
84 > Enable execution of CGI scripts inside the given directory (relative
85 > to the document root.) Cannot be provided more than once.
89 When CGI scripts are enabled for a directory, a request for an
90 executable file will execute it and fed its output to the client.
92 The CGI scripts will inherit the environment from
94 with these additional variables set:
114 > the full path: the concatenation of the document root and the request
119 > the query string if present in the request URL, otherwise it
124 > the IP address of the client in dot notation
128 To quickly getting started
130 $ # generate a cert and a key
131 $ openssl req -x509 -newkey rsa:4096 -keyout key.pem \
132 -out cert.pem -days 365 -nodes
134 $ cat <<EOF > docs/index.gmi
138 $ gmid -c cert.pem -k key.pem -d docs
140 Now you can visit gemini://localhost/ with your preferred gemini
143 To add some CGI scripts, assuming a setup similar to the previous
147 $ cat <<EOF > docs/cgi-bin/hello-world
149 printf "20 text/plain\r\n"
154 Note that the argument to the
160 since it’s relative to the document root.
164 * it doesn't support virtual hosts: the host part of the request URL is
167 * it doesn't fork in the background or anything like that.