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