2020-10-02 19:39:00 +02:00
|
|
|
|
|
|
|
# NAME
|
|
|
|
|
2020-10-03 17:49:09 +02:00
|
|
|
**gmid** - dead simple zero configuration gemini server
|
2020-10-02 19:39:00 +02:00
|
|
|
|
|
|
|
# SYNOPSIS
|
|
|
|
|
|
|
|
**gmid**
|
2020-11-06 13:01:31 +01:00
|
|
|
\[**-hx**]
|
2020-10-02 19:39:00 +02:00
|
|
|
\[**-c** *cert.pem*]
|
|
|
|
\[**-d** *docs*]
|
|
|
|
\[**-k** *key.pem*]
|
2020-11-06 10:58:30 +01:00
|
|
|
\[**-l** *access.log*]
|
2020-10-02 19:39:00 +02:00
|
|
|
|
|
|
|
# DESCRIPTION
|
|
|
|
|
|
|
|
**gmid**
|
|
|
|
is a very simple and minimal gemini server.
|
|
|
|
It only supports serving static content, and strive to be as simple as
|
|
|
|
possible.
|
|
|
|
|
|
|
|
**gmid**
|
|
|
|
will strip any sequence of
|
|
|
|
*../*
|
|
|
|
or trailing
|
|
|
|
*..*
|
|
|
|
in the requests made by clients, so it's impossible to serve content
|
|
|
|
outside the
|
|
|
|
*docs*
|
2020-10-03 17:49:09 +02:00
|
|
|
directory by mistake, and will also refuse to follow symlink.
|
2020-10-02 19:44:32 +02:00
|
|
|
Furthermore, on
|
|
|
|
OpenBSD,
|
|
|
|
pledge(2)
|
2020-10-02 19:39:00 +02:00
|
|
|
and
|
2020-10-02 19:44:32 +02:00
|
|
|
unveil(2)
|
2020-10-02 19:39:00 +02:00
|
|
|
are used to ensure that
|
|
|
|
**gmid**
|
|
|
|
dosen't do anything else than read files from the given directory and
|
|
|
|
accept network connections.
|
|
|
|
|
|
|
|
It should be noted that
|
|
|
|
**gmid**
|
|
|
|
is very simple in its implementation, and so it may not be appropriate
|
|
|
|
for serving site with lots of users.
|
2020-11-05 17:06:12 +01:00
|
|
|
After all, the code is single threaded and use a single process
|
|
|
|
(multiple requests are handled concurrently thanks to async I/O.)
|
2020-10-02 19:39:00 +02:00
|
|
|
|
2020-10-03 17:49:09 +02:00
|
|
|
If a user request path is a directory,
|
|
|
|
**gmid**
|
|
|
|
will try to serve a
|
|
|
|
*index.gmi*
|
|
|
|
file inside that directory.
|
|
|
|
If not found, it will return an error 51 (not found) to the user.
|
|
|
|
|
2020-10-02 19:39:00 +02:00
|
|
|
The options are as follows:
|
|
|
|
|
|
|
|
**-c** *cert.pem*
|
|
|
|
|
|
|
|
> The certificate to use, by default is
|
2020-10-03 17:49:09 +02:00
|
|
|
> *cert.pem*.
|
2020-10-02 19:39:00 +02:00
|
|
|
|
|
|
|
**-d** *docs*
|
|
|
|
|
|
|
|
> The root directory to serve.
|
|
|
|
> **gmid**
|
|
|
|
> won't serve any file that is outside that directory.
|
|
|
|
|
|
|
|
**-h**
|
|
|
|
|
2020-10-03 17:49:09 +02:00
|
|
|
> Print the usage and exit.
|
2020-10-02 19:39:00 +02:00
|
|
|
|
|
|
|
**-k** *key.pem*
|
|
|
|
|
|
|
|
> The key for the certificate, by default is
|
2020-10-03 17:49:09 +02:00
|
|
|
> *key.pem*.
|
2020-10-02 19:39:00 +02:00
|
|
|
|
2020-11-06 10:58:30 +01:00
|
|
|
**-l** *access.log*
|
|
|
|
|
|
|
|
> log to the given file instead of the standard error.
|
|
|
|
|
2020-11-06 13:01:31 +01:00
|
|
|
**-x**
|
|
|
|
|
|
|
|
> Enable CGI scripts.
|
|
|
|
|
|
|
|
# CGI
|
|
|
|
|
|
|
|
If CGI scripts are enabled, when a file requested by a client is
|
|
|
|
marked as executable it is executed and its output fed to the client.
|
|
|
|
|
|
|
|
Note that since this give the chance to anybody to execute possibly
|
|
|
|
**any file**
|
|
|
|
in the served directory, this option is disabled by default.
|
|
|
|
|
2020-10-02 19:39:00 +02:00
|
|
|
# EXAMPLES
|
|
|
|
|
|
|
|
To quickly getting started
|
|
|
|
|
|
|
|
$ # generate a cert and a key
|
|
|
|
$ openssl req -x509 -newkey rsa:4096 -keyout key.pem \
|
|
|
|
-out cert.pem -days 365 -nodes
|
|
|
|
$ mkdir docs
|
|
|
|
$ cat <<EOF > docs/index.gmi
|
|
|
|
# Hello world
|
|
|
|
test paragraph...
|
|
|
|
EOF
|
|
|
|
$ gmid -c cert.pem -k key.pem -d docs
|
|
|
|
|
2020-10-02 19:44:32 +02:00
|
|
|
now you can visit gemini://localhost/ with your preferred gemini client.
|
2020-10-02 19:39:00 +02:00
|
|
|
|
|
|
|
# CAVEATS
|
|
|
|
|
2020-10-03 17:49:09 +02:00
|
|
|
* it doesn't support virtual hosts: the host part of the request URL is
|
2020-10-02 19:39:00 +02:00
|
|
|
completely ignored.
|
|
|
|
|
|
|
|
* it doesn't fork in the background or anything like that.
|
|
|
|
|