Blame


1 f28d96d3 2021-01-25 op .\" Copyright (c) 2021 Omar Polo <op@omarpolo.com>
2 3e4749f7 2020-10-02 op .\"
3 3e4749f7 2020-10-02 op .\" Permission to use, copy, modify, and distribute this software for any
4 3e4749f7 2020-10-02 op .\" purpose with or without fee is hereby granted, provided that the above
5 3e4749f7 2020-10-02 op .\" copyright notice and this permission notice appear in all copies.
6 3e4749f7 2020-10-02 op .\"
7 3e4749f7 2020-10-02 op .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 3e4749f7 2020-10-02 op .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 3e4749f7 2020-10-02 op .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 3e4749f7 2020-10-02 op .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 3e4749f7 2020-10-02 op .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 3e4749f7 2020-10-02 op .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13 3e4749f7 2020-10-02 op .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 39a7b611 2021-01-30 op .Dd $Mdocdate: January 30 2021$
15 3e4749f7 2020-10-02 op .Dt GMIND 1
16 3e4749f7 2020-10-02 op .Os
17 3e4749f7 2020-10-02 op .Sh NAME
18 3e4749f7 2020-10-02 op .Nm gmid
19 714685c1 2021-01-30 op .Nd simple and secure Gemini server
20 3e4749f7 2020-10-02 op .Sh SYNOPSIS
21 3e4749f7 2020-10-02 op .Nm
22 3e4749f7 2020-10-02 op .Bk -words
23 38d4db74 2021-02-04 op .Op Fl fnv
24 15902770 2021-01-15 op .Op Fl c Ar config
25 38d4db74 2021-02-04 op .Ek
26 38d4db74 2021-02-04 op .Nm
27 38d4db74 2021-02-04 op .Bk -words
28 8904fa0e 2021-01-27 op .Op Fl 6hv
29 f28d96d3 2021-01-25 op .Op Fl d Pa certs-dir
30 f28d96d3 2021-01-25 op .Op Fl H Ar hostname
31 721e2325 2020-11-18 op .Op Fl p Ar port
32 f28d96d3 2021-01-25 op .Op Fl x Pa cgi
33 f28d96d3 2021-01-25 op .Op Pa dir
34 3e4749f7 2020-10-02 op .Ek
35 3e4749f7 2020-10-02 op .Sh DESCRIPTION
36 3e4749f7 2020-10-02 op .Nm
37 b9220ca4 2021-01-11 op is a simple and minimal gemini server that can serve static files and
38 b9220ca4 2021-01-11 op execute CGI scripts.
39 eb699783 2021-01-18 op It can run without a configuration file with a limited set of features
40 eb699783 2021-01-18 op available.
41 3007f565 2021-02-04 op .Pp
42 3007f565 2021-02-04 op .Nm
43 3007f565 2021-02-04 op rereads the configuration file when it receives
44 3007f565 2021-02-04 op .Dv SIGHUP .
45 3e4749f7 2020-10-02 op .Pp
46 eb699783 2021-01-18 op The options are as follows:
47 f28d96d3 2021-01-25 op .Bl -tag -width 14m
48 eb699783 2021-01-18 op .It Fl c Pa config
49 f28d96d3 2021-01-25 op Specify the configuration file.
50 46af8c6c 2021-01-27 op .It Fl f
51 46af8c6c 2021-01-27 op Stays and logs on the foreground.
52 eb699783 2021-01-18 op .It Fl n
53 eb699783 2021-01-18 op Check that the configuration is valid, but don't start the server.
54 eb699783 2021-01-18 op .El
55 3e4749f7 2020-10-02 op .Pp
56 eb699783 2021-01-18 op If no configuration file is given,
57 fab952e1 2020-10-03 op .Nm
58 f28d96d3 2021-01-25 op will look for the following options
59 f28d96d3 2021-01-25 op .Bl -tag -width 14m
60 85dff1f9 2021-01-11 op .It Fl 6
61 85dff1f9 2021-01-11 op Enable IPv6.
62 f28d96d3 2021-01-25 op .It Fl d Pa certs-path
63 f28d96d3 2021-01-25 op Directory where certificates for the config-less mode are stored.
64 f28d96d3 2021-01-25 op By default is
65 f28d96d3 2021-01-25 op .Pa $XDG_DATA_HOME/gmid ,
66 f28d96d3 2021-01-25 op i.e.
67 f28d96d3 2021-01-25 op .Pa ~/.local/share/gmid .
68 71cf3975 2021-01-25 op .It Fl H Ar hostname
69 f28d96d3 2021-01-25 op The hostname, by default
70 f28d96d3 2021-01-25 op .Ar localhost .
71 f28d96d3 2021-01-25 op Certificates for the given
72 f28d96d3 2021-01-25 op .Ar hostname
73 f28d96d3 2021-01-25 op are searched inside the
74 f28d96d3 2021-01-25 op .Pa certs-dir
75 f28d96d3 2021-01-25 op directory given with the
76 f28d96d3 2021-01-25 op .Fl d
77 f28d96d3 2021-01-25 op option.
78 714685c1 2021-01-30 op They have the form
79 f28d96d3 2021-01-25 op .Pa hostname.cert.pem
80 f28d96d3 2021-01-25 op and
81 f28d96d3 2021-01-25 op .Pa hostname.key.pem .
82 f28d96d3 2021-01-25 op If a certificate and key doesn't exists for a given hostname they
83 714685c1 2021-01-30 op will be automatically generated.
84 3e4749f7 2020-10-02 op .It Fl h
85 fab952e1 2020-10-03 op Print the usage and exit.
86 721e2325 2020-11-18 op .It Fl p Ar port
87 eb699783 2021-01-18 op The port to listen on, by default 1965.
88 8904fa0e 2021-01-27 op .It Fl v
89 3abf91b0 2021-02-07 op Verbose mode.
90 3abf91b0 2021-02-07 op Multiple
91 3abf91b0 2021-02-07 op .Fl v
92 3abf91b0 2021-02-07 op options increase the verbosity.
93 f28d96d3 2021-01-25 op .It Fl x Pa path
94 eb699783 2021-01-18 op Enable execution of CGI scripts.
95 eb699783 2021-01-18 op See the description of the
96 eb699783 2021-01-18 op .Ic cgi
97 eb699783 2021-01-18 op option in the section
98 eb699783 2021-01-18 op .Sq Servers
99 eb699783 2021-01-18 op below to learn how
100 f28d96d3 2021-01-25 op .Pa path
101 eb699783 2021-01-18 op is processed.
102 eb699783 2021-01-18 op Cannot be provided more than once.
103 f28d96d3 2021-01-25 op .It Pa dir
104 f28d96d3 2021-01-25 op The root directory to serve.
105 f28d96d3 2021-01-25 op By default the current working directory is assumed.
106 3e4749f7 2020-10-02 op .El
107 eb699783 2021-01-18 op .Sh CONFIGURATION FILE
108 eb699783 2021-01-18 op The configuration file is divided into two sections:
109 eb699783 2021-01-18 op .Bl -tag -width xxxx
110 eb699783 2021-01-18 op .It Sy Global Options
111 eb699783 2021-01-18 op Global settings for
112 eb699783 2021-01-18 op .Nm .
113 eb699783 2021-01-18 op .It Sy Servers
114 f28d96d3 2021-01-25 op Virtual hosts definition.
115 eb699783 2021-01-18 op .El
116 eb699783 2021-01-18 op .Pp
117 eb699783 2021-01-18 op Within the sections, empty lines are ignored and comments can be put
118 eb699783 2021-01-18 op anywhere in the file using a hash mark
119 eb699783 2021-01-18 op .Pq Sq # ,
120 eb699783 2021-01-18 op and extend to the end of the current line.
121 eb699783 2021-01-18 op A boolean is either the symbol
122 eb699783 2021-01-18 op .Sq on
123 eb699783 2021-01-18 op or
124 eb699783 2021-01-18 op .Sq off .
125 f28d96d3 2021-01-25 op A string is a sequence of characters wrapped in double quotes,
126 f28d96d3 2021-01-25 op .Dq like this .
127 eb699783 2021-01-18 op .Ss Global Options
128 eb699783 2021-01-18 op .Bl -tag -width 12m
129 ae08ec7d 2021-01-25 op .It Ic chroot Pa path
130 ae08ec7d 2021-01-25 op .Xr chroot 2
131 ae08ec7d 2021-01-25 op the process to the given
132 ae08ec7d 2021-01-25 op .Pa path .
133 ae08ec7d 2021-01-25 op The daemon has to be run with root privileges and thus the option
134 ae08ec7d 2021-01-25 op .Ic user
135 714685c1 2021-01-30 op needs to be provided, so privileges can be dropped.
136 714685c1 2021-01-30 op Note that
137 ae08ec7d 2021-01-25 op .Nm
138 714685c1 2021-01-30 op will enter the chroot after loading the TLS keys, but before opening
139 714685c1 2021-01-30 op the virtual host root directories.
140 714685c1 2021-01-30 op It's recommended to keep the TLS keys outside the chroot.
141 ae08ec7d 2021-01-25 op Future version of
142 ae08ec7d 2021-01-25 op .Nm
143 ae08ec7d 2021-01-25 op may require this.
144 2b92a447 2021-02-06 op .It Ic ipv6 Ar bool
145 2b92a447 2021-02-06 op Enable or disable IPv6 support.
146 2b92a447 2021-02-06 op By default is off.
147 2b92a447 2021-02-06 op .It Ic mime Ar mime-type Ar file-extension
148 2b92a447 2021-02-06 op Add a mapping for the given
149 2b92a447 2021-02-06 op .Ar file-extension
150 2b92a447 2021-02-06 op to the given
151 2b92a447 2021-02-06 op .Ar mime-type .
152 2b92a447 2021-02-06 op Both argument are strings.
153 2b92a447 2021-02-06 op .It Ic port Ar portno
154 2b92a447 2021-02-06 op The port to listen on.
155 2b92a447 2021-02-06 op By default is 1965.
156 a709ddf5 2021-02-07 op .It Ic prefork Ar number
157 a709ddf5 2021-02-07 op Run the specified number of server processes.
158 a709ddf5 2021-02-07 op This increases the performance and prevents delays when connecting to
159 a709ddf5 2021-02-07 op a server.
160 a709ddf5 2021-02-07 op .Nm
161 a709ddf5 2021-02-07 op runs 3 server processes by default, when not in config-less mode.
162 2b92a447 2021-02-06 op .It Ic protocols Ar string
163 2b92a447 2021-02-06 op Specify the TLS protocols to enable.
164 2b92a447 2021-02-06 op Refer to
165 2b92a447 2021-02-06 op .Xr tls_config_parse_protocols 3
166 2b92a447 2021-02-06 op for the valid protocol string values.
167 2b92a447 2021-02-06 op By default, both TLSv1.3 and TLSv1.2 are enabled.
168 2b92a447 2021-02-06 op Use
169 2b92a447 2021-02-06 op .Dq tlsv1.3
170 2b92a447 2021-02-06 op to enable only TLSv1.3.
171 ae08ec7d 2021-01-25 op .It Ic user Ar string
172 ae08ec7d 2021-01-25 op Run the daemon as the given user.
173 eb699783 2021-01-18 op .El
174 eb699783 2021-01-18 op .Ss Servers
175 eb699783 2021-01-18 op Every virtual host is defined by a
176 eb699783 2021-01-18 op .Ic server
177 eb699783 2021-01-18 op block:
178 eb699783 2021-01-18 op .Bl -tag -width Ds
179 eb699783 2021-01-18 op .It Ic server Ar hostname Brq ...
180 75fbb178 2021-01-28 op Match the server name using shell globbing rules.
181 75fbb178 2021-01-28 op This can be an explicit name,
182 de27389e 2021-01-21 op .Ar www.example.com ,
183 de27389e 2021-01-21 op or a name including a wildcards,
184 de27389e 2021-01-21 op .Ar *.example.com .
185 eb699783 2021-01-18 op .El
186 eb699783 2021-01-18 op .Pp
187 eb699783 2021-01-18 op Followed by a block of options that is enclosed in curly brackets:
188 eb699783 2021-01-18 op .Bl -tag -width Ds
189 2b92a447 2021-02-06 op .It Ic auto Ic index Ar bool
190 2b92a447 2021-02-06 op If no index file is found, automatically generate a directory listing.
191 2b92a447 2021-02-06 op It's disabled by default.
192 2b92a447 2021-02-06 op .It Ic block Op Ic return Ar code Op Ar meta
193 2b92a447 2021-02-06 op Send a reply and close the connection;
194 2b92a447 2021-02-06 op .Ar code
195 2b92a447 2021-02-06 op is 40
196 2b92a447 2021-02-06 op and
197 2b92a447 2021-02-06 op .Ar meta
198 2b92a447 2021-02-06 op is
199 2b92a447 2021-02-06 op .Dq temporary failure
200 2b92a447 2021-02-06 op by default.
201 2b92a447 2021-02-06 op If
202 2b92a447 2021-02-06 op .Ar code
203 2b92a447 2021-02-06 op is in the 3x range, then
204 2b92a447 2021-02-06 op .Ar meta
205 2b92a447 2021-02-06 op must be provided.
206 2b92a447 2021-02-06 op Inside
207 2b92a447 2021-02-06 op .Ar meta ,
208 2b92a447 2021-02-06 op the following special sequences are replaced:
209 2b92a447 2021-02-06 op .Bl -tag -compact
210 2b92a447 2021-02-06 op .It \&%\&%
211 2b92a447 2021-02-06 op is replaced with a single
212 2b92a447 2021-02-06 op .Sq \&% .
213 2b92a447 2021-02-06 op .It \&%p
214 2b92a447 2021-02-06 op is replaced with the request path.
215 2b92a447 2021-02-06 op .It \&%q
216 2b92a447 2021-02-06 op is replaced with the query string of the request.
217 2b92a447 2021-02-06 op .It \&%P
218 2b92a447 2021-02-06 op is replaced with the server port.
219 2b92a447 2021-02-06 op .It \&%N
220 2b92a447 2021-02-06 op is replaced with the server name.
221 2b92a447 2021-02-06 op .El
222 eb699783 2021-01-18 op .It Ic cert Pa file
223 eb699783 2021-01-18 op Path to the certificate to use for this server.
224 eb699783 2021-01-18 op The
225 eb699783 2021-01-18 op .Pa file
226 eb699783 2021-01-18 op should contain a PEM encoded certificate.
227 eb699783 2021-01-18 op This option is mandatory.
228 eb699783 2021-01-18 op .It Ic cgi Pa path
229 87f2b68b 2021-02-02 op Execute CGI scripts that matches
230 eb699783 2021-01-18 op .Pa path
231 87f2b68b 2021-02-02 op using shell globbing rules.
232 6119e13e 2021-01-19 op .It Ic default type Ar string
233 6119e13e 2021-01-19 op Set the default media type that is used if the media type for a
234 6119e13e 2021-01-19 op specified extension is not found.
235 6119e13e 2021-01-19 op If not specified, the
236 6119e13e 2021-01-19 op .Ic default type
237 6119e13e 2021-01-19 op is set to
238 6119e13e 2021-01-19 op .Dq application/octet-stream .
239 2b92a447 2021-02-06 op .It Ic entrypoint Pa path
240 2b92a447 2021-02-06 op Make the CGI script at
241 2b92a447 2021-02-06 op .Pa path
242 2b92a447 2021-02-06 op .Pq relative to the Ic root No directory
243 2b92a447 2021-02-06 op handle all the requests for the current virtual host
244 2b92a447 2021-02-06 op .It Ic index Ar string
245 2b92a447 2021-02-06 op Set the directory index file.
246 2b92a447 2021-02-06 op If not specified, it defaults to
247 2b92a447 2021-02-06 op .Pa index.gmi .
248 2b92a447 2021-02-06 op .It Ic key Pa file
249 2b92a447 2021-02-06 op Specify the private key to use for this server.
250 2b92a447 2021-02-06 op The
251 2b92a447 2021-02-06 op .Pa file
252 2b92a447 2021-02-06 op should contain a PEM encoded private key.
253 2b92a447 2021-02-06 op This option is mandatory.
254 05c23a54 2021-01-19 op .It Ic lang Ar string
255 05c23a54 2021-01-19 op Specify the language tag for the text/gemini content served.
256 05c23a54 2021-01-19 op If not specified, no
257 05c23a54 2021-01-19 op .Dq lang
258 05c23a54 2021-01-19 op parameter will be added in the response.
259 c8b74339 2021-01-24 op .It Ic location Pa path Brq ...
260 c8b74339 2021-01-24 op Specify server configuration rules for a specific location.
261 c8b74339 2021-01-24 op The
262 c8b74339 2021-01-24 op .Pa path
263 c8b74339 2021-01-24 op argument will be matched against the request path with shell globbing
264 c8b74339 2021-01-24 op rules.
265 6016a593 2021-01-30 op In case of multiple location statements in the same context, the first
266 6016a593 2021-01-30 op matching location will be put into effect and the later ones ignored.
267 6016a593 2021-01-30 op Therefore is advisable to match for more specific paths first and for
268 6016a593 2021-01-30 op generic ones later on.
269 c8b74339 2021-01-24 op A
270 c8b74339 2021-01-24 op .Ic location
271 c8b74339 2021-01-24 op section may include most of the server configuration rules
272 c8b74339 2021-01-24 op except
273 2b92a447 2021-02-06 op .Ic cert , Ic key , Ic root , Ic location ,
274 e3ddf390 2021-02-06 op .Ic entrypoint No and Ic cgi .
275 2b92a447 2021-02-06 op .It Ic root Pa directory
276 2b92a447 2021-02-06 op Specify the root directory for this server.
277 2b92a447 2021-02-06 op This option is mandatory.
278 2b92a447 2021-02-06 op It's relative to the chroot, if enabled.
279 02be96c6 2021-02-09 op .It Ic require Ic client Ic ca Pa path
280 02be96c6 2021-02-09 op Allow requests only from clients that provide a certificate signed by
281 02be96c6 2021-02-09 op the CA certificate in
282 02be96c6 2021-02-09 op .Pa path .
283 02be96c6 2021-02-09 op It needs to be a PEM-encoded certificate and it's not relative to the
284 02be96c6 2021-02-09 op chroot.
285 6abda252 2021-02-06 op .It Ic strip Ar number
286 6abda252 2021-02-06 op Strip
287 6abda252 2021-02-06 op .Ar number
288 6abda252 2021-02-06 op components from the beginning of the path.
289 6abda252 2021-02-06 op It's only considered for the
290 6abda252 2021-02-06 op .Ar meta
291 2b92a447 2021-02-06 op parameter in the scope of a
292 6abda252 2021-02-06 op .Ic block return .
293 6abda252 2021-02-06 op .El
294 72342dc9 2020-11-06 op .Sh CGI
295 87f2b68b 2021-02-02 op When a request for an executable file matches the
296 87f2b68b 2021-02-02 op .Ic cgi
297 87f2b68b 2021-02-02 op rule, that file will be execute and its output fed to the client.
298 72342dc9 2020-11-06 op .Pp
299 ee655e64 2021-02-01 op The CGI scripts are executed in the directory they reside and inherit
300 a7b9bb4d 2021-01-24 op the environment from
301 0ed56567 2020-11-06 op .Nm
302 0ed56567 2020-11-06 op with these additional variables set:
303 ee655e64 2021-02-01 op .Bl -tag -width 24m
304 28ec6178 2021-01-24 op .It Ev GATEWAY_INTERFACE
305 ee655e64 2021-02-01 op .Dq CGI/1.1
306 ee655e64 2021-02-01 op .It Ev GEMINI_DOCUMENT_ROOT
307 ee655e64 2021-02-01 op The root directory of the virtual host.
308 ee655e64 2021-02-01 op .It Ev GEMINI_SCRIPT_FILENAME
309 ee655e64 2021-02-01 op Full path to the CGI script being executed.
310 ee655e64 2021-02-01 op .It Ev GEMINI_URL
311 ee655e64 2021-02-01 op The full IRI of the request.
312 ee655e64 2021-02-01 op .It Ev GEMINI_URL_PATH
313 ee655e64 2021-02-01 op The path of the request.
314 ee655e64 2021-02-01 op .It Ev PATH_INFO
315 ee655e64 2021-02-01 op The portion of the requested path that is derived from the the IRI
316 ee655e64 2021-02-01 op path hierarchy following the part that identifies the script itself.
317 ee655e64 2021-02-01 op Can be unset.
318 ee655e64 2021-02-01 op .It Ev PATH_TRANSLATED
319 ee655e64 2021-02-01 op Present if and only if
320 ee655e64 2021-02-01 op .Ev PATH_INFO
321 ee655e64 2021-02-01 op is set.
322 ee655e64 2021-02-01 op It represent the translation of the
323 ee655e64 2021-02-01 op .Ev PATH_INFO .
324 ee655e64 2021-02-01 op .Nm
325 ee655e64 2021-02-01 op builds this by appending the
326 ee655e64 2021-02-01 op .Ev PATH_INFO
327 ee655e64 2021-02-01 op to the virtual host directory root.
328 ee655e64 2021-02-01 op .It Ev QUERY_STRING
329 ee655e64 2021-02-01 op The decoded query string.
330 ee655e64 2021-02-01 op .It Ev REMOTE_ADDR , Ev REMOTE_HOST
331 ee655e64 2021-02-01 op Textual representation of the client IP.
332 ee655e64 2021-02-01 op .It Ev REQUEST_METHOD
333 ee655e64 2021-02-01 op This is present only for RFC3875 (CGI) compliance.
334 ee655e64 2021-02-01 op It's always set to the empty string.
335 ee655e64 2021-02-01 op .It Ev SCRIPT_NAME
336 ee655e64 2021-02-01 op The part of the
337 ee655e64 2021-02-01 op .Ev GEMINI_URL_PATH
338 ee655e64 2021-02-01 op that identifies the current CGI script.
339 ee655e64 2021-02-01 op .It Ev SERVER_NAME
340 ee655e64 2021-02-01 op The name of the server
341 ee655e64 2021-02-01 op .It Ev SERVER_PORT
342 ee655e64 2021-02-01 op The port the server is listening on.
343 28ec6178 2021-01-24 op .It Ev SERVER_PROTOCOL
344 ee655e64 2021-02-01 op .Dq GEMINI
345 0ed56567 2020-11-06 op .It Ev SERVER_SOFTWARE
346 ee655e64 2021-02-01 op The name and version of the server, i.e.
347 ee655e64 2021-02-01 op .Dq gmid/1.5
348 677afbd3 2020-12-02 op .It Ev AUTH_TYPE
349 28ec6178 2021-01-24 op The string "Certificate" if the client used a certificate, otherwise
350 28ec6178 2021-01-24 op unset.
351 677afbd3 2020-12-02 op .It Ev REMOTE_USER
352 677afbd3 2020-12-02 op The subject of the client certificate if provided, otherwise unset.
353 677afbd3 2020-12-02 op .It Ev TLS_CLIENT_ISSUER
354 28ec6178 2021-01-24 op The is the issuer of the client certificate if provided, otherwise
355 28ec6178 2021-01-24 op unset.
356 677afbd3 2020-12-02 op .It Ev TLS_CLIENT_HASH
357 677afbd3 2020-12-02 op The hash of the client certificate if provided, otherwise unset.
358 ee655e64 2021-02-01 op The format is
359 ee655e64 2021-02-01 op .Dq ALGO:HASH .
360 b63e30ff 2021-02-07 op .It Ev TLS_CLIENT_NOT_AFTER
361 b63e30ff 2021-02-07 op The time corresponding to the end of the validity period of the peer
362 b63e30ff 2021-02-07 op certificate in the ISO 8601 format
363 b63e30ff 2021-02-07 op .Pq e.g. Dq 2021-02-07T20:17:41Z .
364 b63e30ff 2021-02-07 op .It Ev TLS_CLIENT_NOT_BEFORE
365 b63e30ff 2021-02-07 op The time corresponding to the start of the validity period of the peer
366 b63e30ff 2021-02-07 op certificate in the ISO 8601 format.
367 0ed56567 2020-11-06 op .El
368 a5d310bc 2020-11-10 op .Pp
369 75fbb178 2021-01-28 op .Sh MIME
370 75fbb178 2021-01-28 op To auto-detect the MIME type of the response
371 75fbb178 2021-01-28 op .Nm
372 75fbb178 2021-01-28 op looks at the file extension and consults its internal table.
373 75fbb178 2021-01-28 op By default the following mappings are loaded, but they can be
374 75fbb178 2021-01-28 op overridden or extended using the
375 75fbb178 2021-01-28 op .Ic mime
376 75fbb178 2021-01-28 op configuration option.
377 75fbb178 2021-01-28 op If no MIME is found, the value of
378 75fbb178 2021-01-28 op .Ic default type
379 75fbb178 2021-01-28 op matching the file
380 75fbb178 2021-01-28 op .Ic location
381 75fbb178 2021-01-28 op will be used, which is
382 75fbb178 2021-01-28 op .Dq application/octet-stream
383 75fbb178 2021-01-28 op by default.
384 75fbb178 2021-01-28 op .Pp
385 75fbb178 2021-01-28 op .Bl -tag -offset indent -width 14m -compact
386 75fbb178 2021-01-28 op .It gemini, gmi
387 75fbb178 2021-01-28 op text/gemini
388 75fbb178 2021-01-28 op .It gif
389 75fbb178 2021-01-28 op image/gif
390 75fbb178 2021-01-28 op .It jpeg
391 75fbb178 2021-01-28 op image/jpeg
392 75fbb178 2021-01-28 op .It jpg
393 75fbb178 2021-01-28 op image/jpeg
394 75fbb178 2021-01-28 op .It markdown, md
395 75fbb178 2021-01-28 op text/markdown
396 75fbb178 2021-01-28 op .It pdf
397 75fbb178 2021-01-28 op application/pdf
398 75fbb178 2021-01-28 op .It png
399 75fbb178 2021-01-28 op image/png
400 75fbb178 2021-01-28 op .It svg
401 75fbb178 2021-01-28 op image/svg+xml
402 75fbb178 2021-01-28 op .It txt
403 75fbb178 2021-01-28 op text/plain
404 75fbb178 2021-01-28 op .It xml
405 75fbb178 2021-01-28 op text/xml
406 75fbb178 2021-01-28 op .El
407 3e4749f7 2020-10-02 op .Sh EXAMPLES
408 f28d96d3 2021-01-25 op Serve the current directory
409 6980aad6 2020-10-02 op .Bd -literal -offset indent
410 f28d96d3 2021-01-25 op $ gmid .
411 6980aad6 2020-10-02 op .Ed
412 3e4749f7 2020-10-02 op .Pp
413 f28d96d3 2021-01-25 op To serve the directory
414 f28d96d3 2021-01-25 op .Pa docs
415 f28d96d3 2021-01-25 op and enable CGI scripts inside
416 f28d96d3 2021-01-25 op .Pa docs/cgi ,
417 f28d96d3 2021-01-25 op you can
418 0ed56567 2020-11-06 op .Bd -literal -offset indent
419 f28d96d3 2021-01-25 op $ mkdir docs/cgi
420 f28d96d3 2021-01-25 op $ cat <<EOF > cgi/hello
421 0ed56567 2020-11-06 op #!/bin/sh
422 0ed56567 2020-11-06 op printf "20 text/plain\\r\\n"
423 f28d96d3 2021-01-25 op echo "hello world"
424 0ed56567 2020-11-06 op EOF
425 f28d96d3 2021-01-25 op $ chmod +x docs/cgi/hello
426 f28d96d3 2021-01-25 op $ gmid -x cgi docs
427 0ed56567 2020-11-06 op .Ed
428 0ed56567 2020-11-06 op .Pp
429 eb699783 2021-01-18 op The following is an example of a possible configuration for a site
430 eb699783 2021-01-18 op that enables only TLSv1.3, adds a mime type for the file extension
431 eb699783 2021-01-18 op "rtf" and defines two virtual host:
432 eb699783 2021-01-18 op .Bd -literal -offset indent
433 eb699783 2021-01-18 op ipv6 on # enable ipv6
434 eb699783 2021-01-18 op
435 eb699783 2021-01-18 op protocols "tlsv1.3"
436 eb699783 2021-01-18 op
437 eb699783 2021-01-18 op mime "application/rtf" "rtf"
438 eb699783 2021-01-18 op
439 eb699783 2021-01-18 op server "example.com" {
440 eb699783 2021-01-18 op cert "/path/to/cert.pem"
441 eb699783 2021-01-18 op key "/path/to/key.pem"
442 eb699783 2021-01-18 op root "/var/gemini/example.com"
443 eb699783 2021-01-18 op }
444 eb699783 2021-01-18 op
445 eb699783 2021-01-18 op server "it.example.com" {
446 eb699783 2021-01-18 op cert "/path/to/cert.pem"
447 eb699783 2021-01-18 op key "/path/to/key.pem"
448 eb699783 2021-01-18 op root "/var/gemini/it.example.com"
449 87f2b68b 2021-02-02 op cgi "/cgi-bin/*"
450 de27389e 2021-01-21 op lang "it"
451 eb699783 2021-01-18 op }
452 eb699783 2021-01-18 op .Ed
453 f28d96d3 2021-01-25 op .Pp
454 f28d96d3 2021-01-25 op Yet another example, showing how to enable a
455 f28d96d3 2021-01-25 op .Ic chroot
456 f28d96d3 2021-01-25 op and use
457 f28d96d3 2021-01-25 op .Ic location
458 f28d96d3 2021-01-25 op rule
459 f28d96d3 2021-01-25 op .Bd -literal -offset indent
460 f28d96d3 2021-01-25 op chroot "/var/gemini"
461 f28d96d3 2021-01-25 op user "_gmid"
462 f28d96d3 2021-01-25 op
463 f28d96d3 2021-01-25 op server "example.com" {
464 f28d96d3 2021-01-25 op cert "/path/to/cert.pem"
465 f28d96d3 2021-01-25 op key "/path/to/key.pem"
466 714685c1 2021-01-30 op root "/example.com" # in the /var/gemini chroot
467 f28d96d3 2021-01-25 op
468 4ee08bd1 2021-02-03 op location "/static/*" {
469 f28d96d3 2021-01-25 op auto index on
470 f28d96d3 2021-01-25 op index "index.gemini"
471 f28d96d3 2021-01-25 op }
472 f28d96d3 2021-01-25 op }
473 f28d96d3 2021-01-25 op .Ed
474 ef04b551 2021-01-09 op .Sh ACKNOWLEDGEMENTS
475 ef04b551 2021-01-09 op .Nm
476 eb699783 2021-01-18 op uses the
477 eb699783 2021-01-18 op .Dq Flexible and Economical
478 eb699783 2021-01-18 op UTF-8 decoder written by
479 f28d96d3 2021-01-25 op .An Bjoern Hoehrmann .
480 714685c1 2021-01-30 op .Sh AUTHORS
481 714685c1 2021-01-30 op .An -nosplit
482 714685c1 2021-01-30 op The
483 714685c1 2021-01-30 op .Nm
484 714685c1 2021-01-30 op program was written by
485 714685c1 2021-01-30 op .An Omar Polo Aq Mt op@omarpolo.com .
486 3e4749f7 2020-10-02 op .Sh CAVEATS
487 3e4749f7 2020-10-02 op .Bl -bullet
488 3e4749f7 2020-10-02 op .It
489 eb699783 2021-01-18 op The root directories of all virtual hosts are opened during the daemon
490 eb699783 2021-01-18 op startup; this means that if a root directory gets deleted and then
491 eb699783 2021-01-18 op re-created,
492 eb699783 2021-01-18 op .Nm
493 eb699783 2021-01-18 op won't be able to serve files inside that directory until a restart.
494 eb699783 2021-01-18 op This restriction applies only to the root directories and not their content.
495 043acc97 2020-12-25 op .It
496 714685c1 2021-01-30 op a %2F sequence is indistinguishable from a literal slash: this is not
497 714685c1 2021-01-30 op RFC3986-compliant.
498 00781742 2020-12-25 op .It
499 714685c1 2021-01-30 op a %00 sequence is treated as invalid character and thus rejected.
500 3e4749f7 2020-10-02 op .El