Blob


1 .\" Copyright (c) 2020 Omar Polo <op@omarpolo.com>
2 .\"
3 .\" Permission to use, copy, modify, and distribute this software for any
4 .\" purpose with or without fee is hereby granted, provided that the above
5 .\" copyright notice and this permission notice appear in all copies.
6 .\"
7 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 .Dd $Mdocdate: October 2 2020$
15 .Dt GMIND 1
16 .Os
17 .Sh NAME
18 .Nm gmid
19 .Nd dead simple zero configuration gemini server
20 .Sh SYNOPSIS
21 .Nm
22 .Bk -words
23 .Op Fl h
24 .Op Fl c Ar cert.pem
25 .Op Fl d Ar docs
26 .Op Fl k Ar key.pem
27 .Ek
28 .Sh DESCRIPTION
29 .Nm
30 is a very simple and minimal gemini server.
31 It only supports serving static content, and strive to be as simple as
32 possible.
33 .Pp
34 .Nm
35 will strip any sequence of
36 .Pa ../
37 or trailing
38 .Pa ..
39 in the requests made by clients, so it's impossible to serve content
40 outside the
41 .Pa docs
42 directory by mistake, and will also refuse to follow symlink.
43 Furthermore, on
44 .Ox ,
45 .Xr pledge 2
46 and
47 .Xr unveil 2
48 are used to ensure that
49 .Nm
50 dosen't do anything else than read files from the given directory and
51 accept network connections.
52 .Pp
53 It should be noted that
54 .Nm
55 is very simple in its implementation, and so it may not be appropriate
56 for serving site with lots of users.
57 After all, the code is single threaded and use a single process.
58 .Pp
59 If a user request path is a directory,
60 .Nm
61 will try to serve a
62 .Pa index.gmi
63 file inside that directory.
64 If not found, it will return an error 51 (not found) to the user.
65 .Pp
66 The options are as follows:
67 .Bl -tag -width 12m
68 .It Fl c Ar cert.pem
69 The certificate to use, by default is
70 .Pa cert.pem .
71 .It Fl d Ar docs
72 The root directory to serve.
73 .Nm
74 won't serve any file that is outside that directory.
75 .It Fl h
76 Print the usage and exit.
77 .It Fl k Ar key.pem
78 The key for the certificate, by default is
79 .Pa key.pem .
80 .El
81 .Sh EXAMPLES
82 To quickly getting started
83 .Bd -literal -offset indent
84 $ # generate a cert and a key
85 $ openssl req -x509 -newkey rsa:4096 -keyout key.pem \\
86 -out cert.pem -days 365 -nodes
87 $ mkdir docs
88 $ cat <<EOF > docs/index.gmi
89 # Hello world
90 test paragraph...
91 EOF
92 $ gmid -c cert.pem -k key.pem -d docs
93 .Ed
94 .Pp
95 now you can visit gemini://localhost/ with your preferred gemini client.
96 .Sh CAVEATS
97 .Bl -bullet
98 .It
99 it doesn't support virtual hosts: the host part of the request URL is
100 completely ignored.
101 .It
102 it doesn't fork in the background or anything like that.
103 .El