4 fab952e1 2020-10-03 op **gmid** - dead simple zero configuration gemini server
10 3e4749f7 2020-10-02 op \[**-c** *cert.pem*]
11 3e4749f7 2020-10-02 op \[**-d** *docs*]
12 3e4749f7 2020-10-02 op \[**-k** *key.pem*]
13 2c3a40fa 2020-11-06 op \[**-l** *access.log*]
18 3e4749f7 2020-10-02 op is a very simple and minimal gemini server.
19 3e4749f7 2020-10-02 op It only supports serving static content, and strive to be as simple as
23 3e4749f7 2020-10-02 op will strip any sequence of
27 3e4749f7 2020-10-02 op in the requests made by clients, so it's impossible to serve content
30 fab952e1 2020-10-03 op directory by mistake, and will also refuse to follow symlink.
31 6980aad6 2020-10-02 op Furthermore, on
36 3e4749f7 2020-10-02 op are used to ensure that
38 3e4749f7 2020-10-02 op dosen't do anything else than read files from the given directory and
39 3e4749f7 2020-10-02 op accept network connections.
41 3e4749f7 2020-10-02 op It should be noted that
43 3e4749f7 2020-10-02 op is very simple in its implementation, and so it may not be appropriate
44 3e4749f7 2020-10-02 op for serving site with lots of users.
45 20f68838 2020-11-05 op After all, the code is single threaded and use a single process
46 20f68838 2020-11-05 op (multiple requests are handled concurrently thanks to async I/O.)
48 fab952e1 2020-10-03 op If a user request path is a directory,
50 fab952e1 2020-10-03 op will try to serve a
52 fab952e1 2020-10-03 op file inside that directory.
53 fab952e1 2020-10-03 op If not found, it will return an error 51 (not found) to the user.
55 3e4749f7 2020-10-02 op The options are as follows:
57 3e4749f7 2020-10-02 op **-c** *cert.pem*
59 3e4749f7 2020-10-02 op > The certificate to use, by default is
64 3e4749f7 2020-10-02 op > The root directory to serve.
66 3e4749f7 2020-10-02 op > won't serve any file that is outside that directory.
70 fab952e1 2020-10-03 op > Print the usage and exit.
72 3e4749f7 2020-10-02 op **-k** *key.pem*
74 3e4749f7 2020-10-02 op > The key for the certificate, by default is
77 2c3a40fa 2020-11-06 op **-l** *access.log*
79 2c3a40fa 2020-11-06 op > log to the given file instead of the standard error.
83 0ed56567 2020-11-06 op > Enable execution of CGI scripts inside the given directory (relative
84 0ed56567 2020-11-06 op > to the document root.) Cannot be provided more than once.
88 0ed56567 2020-11-06 op When CGI scripts are enabled for a directory, a request for an
89 0ed56567 2020-11-06 op executable file will execute it and fed its output to the client.
93 3e4749f7 2020-10-02 op To quickly getting started
95 3e4749f7 2020-10-02 op $ # generate a cert and a key
96 3e4749f7 2020-10-02 op $ openssl req -x509 -newkey rsa:4096 -keyout key.pem \
97 3e4749f7 2020-10-02 op -out cert.pem -days 365 -nodes
99 3e4749f7 2020-10-02 op $ cat <<EOF > docs/index.gmi
100 3e4749f7 2020-10-02 op # Hello world
101 3e4749f7 2020-10-02 op test paragraph...
103 3e4749f7 2020-10-02 op $ gmid -c cert.pem -k key.pem -d docs
105 0ed56567 2020-11-06 op now you can visit gemini://localhost/ with your preferred gemini
108 0ed56567 2020-11-06 op To add some CGI scripts, assuming a setup similar to the previous
109 0ed56567 2020-11-06 op example, one can
111 0ed56567 2020-11-06 op $ mkdir docs/cgi-bin
112 0ed56567 2020-11-06 op $ cat <<EOF > docs/cgi-bin/hello-world
114 0ed56567 2020-11-06 op printf "20 text/plain0
115 0ed56567 2020-11-06 op echo "hello world!"
117 0ed56567 2020-11-06 op $ gmid -d docs -x cgi-bin
119 0ed56567 2020-11-06 op note that the argument to the
124 0ed56567 2020-11-06 op *docs/cgi-bin*,
125 0ed56567 2020-11-06 op since it’s relative to the document root.
129 fab952e1 2020-10-03 op * it doesn't support virtual hosts: the host part of the request URL is
130 3e4749f7 2020-10-02 op completely ignored.
132 3e4749f7 2020-10-02 op * it doesn't fork in the background or anything like that.