Blob


1 .\" Copyright (c) 2021, 2022 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: February 26 2022$
15 .Dt GMID 1
16 .Os
17 .Sh NAME
18 .Nm gmid
19 .Nd simple and secure Gemini server
20 .Sh SYNOPSIS
21 .Nm
22 .Bk -words
23 .Op Fl fnv
24 .Op Fl c Ar config
25 .Op Fl D Ar macro Ns = Ns Ar value
26 .Op Fl P Ar pidfile
27 .Ek
28 .Nm
29 .Bk -words
30 .Op Fl 6hVv
31 .Op Fl d Ar certs-dir
32 .Op Fl H Ar hostname
33 .Op Fl p Ar port
34 .Op Fl x Ar cgi
35 .Op Ar dir
36 .Ek
37 .Sh DESCRIPTION
38 .Nm
39 is a simple and minimal gemini server that can serve static files,
40 execute CGI scripts and talk to FastCGI applications.
41 It can run without a configuration file with a limited set of features
42 available.
43 .Pp
44 .Nm
45 rereads the configuration file when it receives
46 .Dv SIGHUP .
47 .Pp
48 The options are as follows:
49 .Bl -tag -width 14m
50 .It Fl c Ar config
51 Specify the configuration file.
52 .It Fl D Ar macro Ns = Ns Ar value
53 Define
54 .Ar macro
55 to be set to
56 .Ar value
57 on the command line.
58 Overrides the definition of
59 .Ar macro
60 in the config file if present.
61 .It Fl f
62 Stays and logs on the foreground.
63 .It Fl n
64 Check that the configuration is valid, but don't start the server.
65 If specified two or more time, dump the configuration in addition to
66 verify it.
67 .It Fl P Ar pidfile
68 Write daemon's pid to the given location.
69 .Ar pidfile
70 will also act as lock: if another process is holding a lock on that
71 file,
72 .Nm
73 will refuse to start.
74 .El
75 .Pp
76 If no configuration file is given,
77 .Nm
78 runs in
79 .Dq config-less mode
80 .Pq i.e. runs in the foreground to serve a directory from the shell
81 and looks for the following options
82 .Bl -tag -width 14m
83 .It Fl 6
84 Enable IPv6.
85 .It Fl d Ar certs-path
86 Directory where certificates for the config-less mode are stored.
87 By default it is
88 .Pa $XDG_DATA_HOME/gmid ,
89 i.e.
90 .Pa ~/.local/share/gmid .
91 .It Fl H Ar hostname
92 The hostname
93 .Po
94 .Ar localhost
95 by default
96 .Pc .
97 Certificates for the given
98 .Ar hostname
99 are searched inside the
100 .Ar certs-dir
101 directory given with the
102 .Fl d
103 option.
104 They have the form
105 .Pa hostname.cert.pem
106 and
107 .Pa hostname.key.pem .
108 If a certificate or a key doesn't exist for a given hostname, they
109 will be generated automatically.
110 .It Fl h , Fl -help
111 Print the usage and exit.
112 .It Fl p Ar port
113 The port to listen on, by default 1965.
114 .It Fl V , Fl -version
115 Print the version and exit.
116 .It Fl v
117 Verbose mode.
118 Multiple
119 .Fl v
120 options increase the verbosity.
121 .It Fl x Ar path
122 Enable execution of
123 .Sx CGI
124 scripts.
125 See the description of the
126 .Ic cgi
127 option in the
128 .Sq Servers
129 section below to learn how
130 .Ar path
131 is processed.
132 Cannot be provided more than once.
133 .It Ar dir
134 The root directory to serve.
135 By default the current working directory is assumed.
136 .El
137 .Sh CONFIGURATION FILE
138 The configuration file is divided into three sections:
139 .Bl -tag -width xxxx
140 .It Sy Macros
141 User-defined variables may be defined and used later, simplifying the
142 configuration file.
143 .It Sy Global Options
144 Global settings for
145 .Nm .
146 .It Sy Servers
147 Virtual hosts definition.
148 .It Sy Types
149 Media types and extensions.
150 .El
151 .Pp
152 Within the sections, empty lines are ignored and comments can be put
153 anywhere in the file using a hash mark
154 .Pq Sq # ,
155 and extend to the end of the current line.
156 A boolean is either the symbol
157 .Sq on
158 or
159 .Sq off .
160 A string is a sequence of characters wrapped in double quotes,
161 .Dq like this .
162 Multiple strings one next to the other are joined into a single
163 string:
164 .Bd -literal -offset indent
165 # equivalent to "temporary-failure"
166 block return 40 "temporary" "-" "failure"
167 .Ed
168 .Pp
169 Furthermore, quoting is necessary only when a string needs to contain
170 special characters
171 .Pq like spaces or punctuation ,
172 something that looks like a number or a reserved keyword.
173 The last example could have been written also as:
174 .Bd -literal -offset indent
175 block return 40 temporary "-" failure
176 .Ed
177 .Pp
178 Strict ordering of the sections is not enforced, so that is possible
179 to mix macros, options and
180 .Ic server
181 blocks.
182 However, defining all the
183 .Ic server
184 blocks after the macros and the global options is recommended.
185 .Pp
186 Newlines are often optional, except around top-level instructions, and
187 semicolons
188 .Dq \&;
189 can also be optionally used to separate options.
190 .Pp
191 Additional configuration files can be included with the
192 .Ic include
193 keyword, for example:
194 .Bd -literal -offset indent
195 include "/etc/gmid.conf.local"
196 .Ed
197 .Ss Macros
198 Macros can be defined that will later be expanded in context.
199 Macro names must start with a letter, digit or underscore and may
200 contain any of those characters.
201 Macros names may not be reserved words.
202 Macros are not expanded inside quotes.
203 .Pp
204 Two kinds of macros are supported: variable-like and proper macros.
205 When a macro is invoked with a
206 .Dq $
207 before its name its expanded as a string, whereas when it's invoked
208 with a
209 .Dq @
210 its expanded in-place.
211 .Pp
212 For example:
213 .Bd -literal -offset indent
214 dir = "/var/gemini"
215 certdir = "/etc/keys"
216 common = "lang it; auto index on"
218 server "foo" {
219 root $dir "/foo" # -> /var/gemini/foo
220 cert $certdir "/foo.crt" # -> /etc/keys/foo.crt
221 key $certdir "/foo.pem" # -> /etc/keys/foo.pem
222 @common
224 .Ed
225 .Ss Global Options
226 .Bl -tag -width 12m
227 .It Ic chroot Ar path
228 .Xr chroot 2
229 the process to the given
230 .Ar path .
231 The daemon has to be run with root privileges and thus the option
232 .Ic user
233 needs to be provided, so privileges can be dropped.
234 Note that
235 .Nm
236 will enter the chroot after loading the TLS keys, but before opening
237 the virtual host root directories.
238 It's recommended to keep the TLS keys outside the chroot.
239 Future version of
240 .Nm
241 may enforce this.
242 .It Ic ipv6 Ar bool
243 Enable or disable IPv6 support, off by default.
244 .It Ic port Ar portno
245 The port to listen on.
246 1965 by default.
247 .It Ic prefork Ar number
248 Run the specified number of server processes.
249 This increases the performance and prevents delays when connecting to
250 a server.
251 When not in config-less mode,
252 .Nm
253 runs 3 server processes by default.
254 The maximum number allowed is 16.
255 .It Ic protocols Ar string
256 Specify the TLS protocols to enable.
257 Refer to
258 .Xr tls_config_parse_protocols 3
259 for the valid protocol string values.
260 By default, both TLSv1.3 and TLSv1.2 are enabled.
261 Use
262 .Dq tlsv1.3
263 to enable only TLSv1.3.
264 .It Ic user Ar string
265 Run the daemon as the given user.
266 .El
267 .Ss Servers
268 Every virtual host is defined by a
269 .Ic server
270 block:
271 .Bl -tag -width Ds
272 .It Ic server Ar hostname Brq ...
273 Match the server name using shell globbing rules.
274 It can be an explicit name,
275 .Ar www.example.com ,
276 or a name including a wildcards,
277 .Ar *.example.com .
278 .El
279 .Pp
280 Followed by a block of options that is enclosed in curly brackets:
281 .Bl -tag -width Ds
282 .It Ic alias Ar name
283 Specify an additional alias
284 .Ar name
285 for this server.
286 .It Ic auto Ic index Ar bool
287 If no index file is found, automatically generate a directory listing.
288 Disabled by default.
289 .It Ic block Op Ic return Ar code Op Ar meta
290 Send a reply and close the connection;
291 by default
292 .Ar code
293 is 40
294 and
295 .Ar meta
296 is
297 .Dq temporary failure .
298 If
299 .Ar code
300 is in the 3x range, then
301 .Ar meta
302 is mandatory.
303 Inside
304 .Ar meta ,
305 the following special sequences are supported:
306 .Bl -tag -width Ds -compact
307 .It \&%\&%
308 is replaced with a single
309 .Sq \&% .
310 .It \&%p
311 is replaced with the request path.
312 .It \&%q
313 is replaced with the query string of the request.
314 .It \&%P
315 is replaced with the server port.
316 .It \&%N
317 is replaced with the server name.
318 .El
319 .It Ic cert Ar file
320 Path to the certificate to use for this server.
321 .Ar file
322 should contain a PEM encoded certificate.
323 This option is mandatory.
324 .It Ic cgi Ar path
325 Execute
326 .Sx CGI
327 scripts that matches
328 .Ar path
329 using shell globbing rules.
330 .It Ic default type Ar string
331 Set the default media type that is used if the media type for a
332 specified extension is not found.
333 If not specified, the
334 .Ic default type
335 is set to
336 .Dq application/octet-stream .
337 .It Ic entrypoint Ar path
338 Handle all the requests for the current virtual host using the
339 .Sx CGI
340 script at
341 .Ar path ,
342 relative to the current document root.
343 .It Ic env Ar name Cm = Ar value
344 Set the environment variable
345 .Ar name
346 to
347 .Ar value
348 when executing CGI scripts.
349 Can be provided more than once.
350 .\" don't document the "spawn <prog>" form because it probably won't
351 .\" be kept.
352 .It Ic fastcgi Oo Ic tcp Oc Ar socket Oo Cm port Ar port Oc
353 Enable
354 .Sx FastCGI
355 instead of serving files.
356 The
357 .Ar socket
358 can either be a UNIX-domain socket or a TCP socket.
359 If the FastCGI application is listening on a UNIX domain socket,
360 .Ar socket
361 is a local path name within the
362 .Xr chroot 2
363 root directory of
364 .Nm .
365 Otherwise, the
366 .Ic tcp
367 keyword must be provided and
368 .Ar socket
369 is interpreted as a hostname or an IP address.
370 .Ar port
371 can be either a port number or the name of a service enclosed in
372 double quotes.
373 If not specified defaults to 9000.
374 .It Ic index Ar string
375 Set the directory index file.
376 If not specified, it defaults to
377 .Pa index.gmi .
378 .It Ic key Ar file
379 Specify the private key to use for this server.
380 .Ar file
381 should contain a PEM encoded private key.
382 This option is mandatory.
383 .It Ic lang Ar string
384 Specify the language tag for the text/gemini content served.
385 If not specified, no
386 .Dq lang
387 parameter will be added in the response.
388 .It Ic location Ar path Brq ...
389 Specify server configuration rules for a specific location.
390 .Ar path
391 argument will be matched against the request path with shell globbing
392 rules.
393 In case of multiple location statements in the same context, the first
394 matching location will be put into effect and the later ones ignored.
395 Therefore is advisable to match for more specific paths first and for
396 generic ones later on.
398 .Ic location
399 section may include most of the server configuration rules
400 except
401 .Ic alias , Ic cert , Ic cgi , Ic entrypoint , Ic env , Ic key ,
402 .Ic location , Ic param No and Ic proxy .
403 .It Ic log Ar bool
404 Enable or disable the logging for the current server or location block.
405 .It Ic param Ar name Cm = Ar value
406 Set the param
407 .Ar name
408 to
409 .Ar value
410 for FastCGI.
411 .It Ic ocsp Ar file
412 Specify an OCSP response to be stapled during TLS handshakes
413 with this server.
414 The
415 .Ar file
416 should contain a DER-format OCSP response retrieved from an
417 OCSP server for the
418 .Ic cert
419 in use.
420 If the OCSP response in
421 .Ar file
422 is empty, OCSP stapling will not be used.
423 The default is to not use OCSP stapling.
424 .It Ic proxy Oo Cm proto Ar name Oc Oo Cm for-host Ar host : Ns Oo Ar port Oc Oc Brq ...
425 Set up a reverse proxy.
426 The optional matching rules
427 .Cm proto
428 and
429 .Cm for-host
430 can be used to enable proxying only for protocols matching
431 .Ar name
432 .Po Dq gemini
433 by default
434 .Pc
435 and/or whose request IRI matches
436 .Ar host
437 and
438 .Ar port
439 .Pq 1965 by default .
440 Matching happens using shell globbing rules.
441 .Pp
442 In case of multiple matching proxy blocks in the same context, the
443 first matching proxy will be put into effect and the later ones
444 ignored.
445 .Pp
446 Valid options are:
447 .Bl -tag -width Ds
448 .It Ic cert Ar file
449 Specify the client certificate to use when making requests.
450 .It Ic key Ar file
451 Specify the client certificate key to use when making requests.
452 .It Ic protocols Ar string
453 Specify the TLS protocols allowed when making remote requests.
454 Refer to the
455 .Xr tls_config_parse_protocols 3
456 function for the valid protocol string values.
457 By default, both TLSv1.2 and TLSv1.3 are enabled.
458 .It Ic relay-to Ar host : Ns Op Ar port
459 Relay the request to the given
460 .Ar host
461 at the given
462 .Ar port ,
463 1965 by default.
464 This is the only mandatory option in a
465 .Ic proxy
466 block.
467 .It Ic require Ic client Ic ca Ar file
468 Allow the proxying only from clients that provide a certificate
469 signed by the CA certificate in
470 .Ar file .
471 .It Ic sni Ar hostname
472 Use the given
473 .Ar hostname
474 instead of the one extracted from the
475 .Ic relay-to
476 rule for the TLS handshake with the proxied gemini server.
477 .It Ic use-tls Ar bool
478 Specify whether to use TLS when connecting to the proxied host.
479 Enabled by default.
480 .It Ic verifyname Ar bool
481 Enable or disable the TLS server name verification.
482 Enabled by default.
483 .El
484 .It Ic root Ar directory
485 Specify the root directory for this server
486 .Pq alas the current Dq document root .
487 It's relative to the chroot if enabled.
488 .It Ic require Ic client Ic ca Ar path
489 Allow requests only from clients that provide a certificate signed by
490 the CA certificate in
491 .Ar path .
492 It needs to be a PEM-encoded certificate and it's not relative to the
493 chroot.
494 .It Ic strip Ar number
495 Strip
496 .Ar number
497 components from the beginning of the path before doing a lookup in the
498 root directory.
499 It's also considered for the
500 .Ar meta
501 parameter in the scope of a
502 .Ic block return .
503 .El
504 .Ss Types
505 The
506 .Ic types
507 section must include one or more lines of the following syntax, enclosed
508 in curly brances:
509 .Bl -tag -width Ds
510 .It Ar type/subtype Ar name Op Ar name ...
511 Set the media
512 .Ar type
513 and
514 .Ar subtype
515 to the specified extension
516 .Ar name .
517 One or more names can be specified per line.
518 Earch line may end with an optional semicolon.
519 .It Ic include Ar file
520 Include types definition from an external file, for example
521 .Pa /usr/share/misc/mime.types .
522 .El
523 .Sh CGI
524 When a request for an executable file matches the
525 .Ic cgi
526 rule, that file will be executed and its output fed to the client.
527 .Pp
528 The CGI scripts are executed in the directory they reside and inherit
529 the environment from
530 .Nm
531 with these additional variables set:
532 .Bl -tag -width 24m
533 .It Ev GATEWAY_INTERFACE
534 .Dq CGI/1.1
535 .It Ev GEMINI_DOCUMENT_ROOT
536 The root directory of the virtual host.
537 .It Ev GEMINI_SCRIPT_FILENAME
538 Full path to the CGI script being executed.
539 .It Ev GEMINI_URL
540 The full IRI of the request.
541 .It Ev GEMINI_URL_PATH
542 The path of the request.
543 .It Ev PATH_INFO
544 The portion of the requested path that is derived from the the IRI
545 path hierarchy following the part that identifies the script itself.
546 Can be unset.
547 .It Ev PATH_TRANSLATED
548 Present if and only if
549 .Ev PATH_INFO
550 is set.
551 It represent the translation of the
552 .Ev PATH_INFO .
553 .Nm
554 builds this by appending the
555 .Ev PATH_INFO
556 to the virtual host directory root.
557 .It Ev QUERY_STRING
558 The decoded query string.
559 .It Ev REMOTE_ADDR , Ev REMOTE_HOST
560 Textual representation of the client IP.
561 .It Ev REQUEST_METHOD
562 This is present only for RFC3875 (CGI) compliance.
563 It's always set to the empty string.
564 .It Ev SCRIPT_NAME
565 The part of the
566 .Ev GEMINI_URL_PATH
567 that identifies the current CGI script.
568 .It Ev SERVER_NAME
569 The name of the server
570 .It Ev SERVER_PORT
571 The port the server is listening on.
572 .It Ev SERVER_PROTOCOL
573 .Dq GEMINI
574 .It Ev SERVER_SOFTWARE
575 The name and version of the server, i.e.
576 .Dq gmid/1.8.3
577 .It Ev AUTH_TYPE
578 The string "Certificate" if the client used a certificate, otherwise
579 unset.
580 .It Ev REMOTE_USER
581 The subject of the client certificate if provided, otherwise unset.
582 .It Ev TLS_CLIENT_ISSUER
583 The is the issuer of the client certificate if provided, otherwise
584 unset.
585 .It Ev TLS_CLIENT_HASH
586 The hash of the client certificate if provided, otherwise unset.
587 The format is
588 .Dq ALGO:HASH .
589 .It Ev TLS_VERSION
590 The TLS version negotiated with the peer.
591 .It Ev TLS_CIPHER
592 The cipher suite negotiated with the peer.
593 .It Ev TLS_CIPHER_STRENGTH
594 The strength in bits for the symmetric cipher that is being used with
595 the peer.
596 .It Ev TLS_CLIENT_NOT_AFTER
597 The time corresponding to the end of the validity period of the peer
598 certificate in the ISO 8601 format
599 .Pq e.g. Dq 2021-02-07T20:17:41Z .
600 .It Ev TLS_CLIENT_NOT_BEFORE
601 The time corresponding to the start of the validity period of the peer
602 certificate in the ISO 8601 format.
603 .El
604 .Sh FastCGI
605 .Nm
606 optionally supports FastCGI.
608 .Ic fastcgi
609 rule must be present in a server or location block.
610 Then, all requests matching that server or location will be handled
611 via the specified FastCGI backend.
612 .Pp
613 By default the following variables
614 .Pq parameters
615 are sent, and carry the same semantics as with CGI.
616 More parameters can be added with the
617 .Ic param
618 option.
619 .Pp
620 .Bl -bullet -compact
621 .It
622 GATEWAY_INTERFACE
623 .It
624 GEMINI_URL_PATH
625 .It
626 QUERY_STRING
627 .It
628 REMOTE_ADDR
629 .It
630 REMOTE_HOST
631 .It
632 REQUEST_METHOD
633 .It
634 SERVER_NAME
635 .It
636 SERVER_PROTOCOL
637 .It
638 SERVER_SOFTWARE
639 .It
640 AUTH_TYPE
641 .It
642 REMOTE_USER
643 .It
644 TLS_CLIENT_ISSUER
645 .It
646 TLS_CLIENT_HASH
647 .It
648 TLS_VERSION
649 .It
650 TLS_CIPHER
651 .It
652 TLS_CIPHER_STRENGTH
653 .It
654 TLS_CLIENT_NOT_BEFORE
655 .It
656 TLS_CLIENT_NOT_AFTER
657 .El
658 .Sh MEDIA TYPES
659 To auto-detect the MIME type of the response
660 .Nm
661 looks at the file extension and consults an internal table.
662 If no MIME is found, the value of
663 .Ic default type
664 matching the file
665 .Ic location
666 will be used, or
667 .Dq application/octet-stream .
668 .Pp
669 By default the following mappings are loaded, but they can be
670 overridden or extended using the
671 .Ic type Brq ...
672 block.
673 .Pp
674 .Bl -tag -offset indent -width 14m -compact
675 .It diff
676 text/x-patch
677 .It gemini, gmi
678 text/gemini
679 .It gif
680 image/gif
681 .It jpeg
682 image/jpeg
683 .It jpg
684 image/jpeg
685 .It markdown, md
686 text/markdown
687 .It patch
688 text/x-patch
689 .It pdf
690 application/pdf
691 .It png
692 image/png
693 .It svg
694 image/svg+xml
695 .It txt
696 text/plain
697 .It xml
698 text/xml
699 .El
700 .Sh LOGGING
701 Messages and requests are logged by
702 .Xr syslog 3
703 using the
704 .Dv DAEMON
705 facility or printed on
706 .Em stderr .
707 .Pp
708 Requests are logged with the
709 .Dv NOTICE
710 severity.
711 Each request log entry has the following fields, separated by
712 whitespace:
713 .Pp
714 .Bl -bullet -compact
715 .It
716 Client IP address and the source port number, separated by a colon
717 .It
718 .Sy GET
719 keyword
720 .It
721 Request URL
722 .It
723 Response status
724 .It
725 Response meta
726 .El
727 .Sh EXAMPLES
728 Serve the current directory
729 .Bd -literal -offset indent
730 $ gmid .
731 .Ed
732 .Pp
733 To serve the directory
734 .Pa docs
735 and enable CGI scripts inside
736 .Pa docs/cgi
737 .Bd -literal -offset indent
738 $ mkdir docs/cgi
739 $ cat <<EOF > docs/cgi/hello
740 #!/bin/sh
741 printf "20 text/plain\er\en"
742 echo "hello world"
743 EOF
744 $ chmod +x docs/cgi/hello
745 $ gmid -x '/cgi/*' docs
746 .Ed
747 .Pp
748 An X.509 certificate must be provided to run
749 .Nm
750 using a configuration file.
751 First, the RSA certificate is created using a wildcard common name:
752 .Bd -literal -offset indent
753 # openssl genrsa \-out /etc/ssl/private/example.com.key 4096
754 # openssl req \-new \-x509 \e
755 \-key /etc/ssl/private/example.com.key \e
756 \-out /etc/ssl/example.com.crt \e
757 \-days 36500 \-nodes \e
758 \-subj "/CN=example.com"
759 # chmod 600 /etc/ssl/example.com.crt
760 # chmod 600 /etc/ssl/private/example.com.key
761 .Ed
762 .Pp
763 In the example above, a certificate is valid for one hundred years from
764 the date it was created, which is normal for TOFU.
765 .Pp
766 The following is an example of a possible configuration for a site
767 that enables only TLSv1.3, adds the MIME types mapping from
768 .Pa /usr/share/misc/mime.types
769 and defines two virtual host:
770 .Bd -literal -offset indent
771 ipv6 on # enable ipv6
773 protocols "tlsv1.3"
775 types {
776 include "/usr/share/misc/mime.types"
779 server "example.com" {
780 cert "/etc/ssl/example.com.crt"
781 key "/etc/ssl/private/example.com.key"
782 root "/var/gemini/example.com"
785 server "it.example.com" {
786 cert "/etc/ssl/example.com.crt"
787 key "/etc/ssl/private/example.com.key"
788 root "/var/gemini/it.example.com"
790 # enable cgi scripts inside "cgi-bin"
791 cgi "/cgi-bin/*"
793 # set the language for text/gemini files
794 lang "it"
796 .Ed
797 .Pp
798 Yet another example, showing how to enable a
799 .Ic chroot
800 and use
801 .Ic location
802 rule
803 .Bd -literal -offset indent
804 chroot "/var/gemini"
805 user "_gmid"
807 server "example.com" {
808 cert "/path/to/cert.pem" # absolute path
809 key "/path/to/key.pem" # also absolute
810 root "/example.com" # relative to the chroot
812 location "/static/*" {
813 # load the following rules only for
814 # requests that matches "/static/*"
816 auto index on
817 index "index.gemini"
820 .Ed
821 .Sh ACKNOWLEDGEMENTS
822 .Nm
823 uses the
824 .Dq Flexible and Economical
825 UTF-8 decoder written by
826 .An Bjoern Hoehrmann .
827 .Sh AUTHORS
828 .An -nosplit
829 The
830 .Nm
831 program was written by
832 .An Omar Polo Aq Mt op@omarpolo.com .
833 .Sh CAVEATS
834 .Bl -bullet
835 .It
836 All the root directories are opened during the daemon startup; if a
837 root directory is deleted and then re-created,
838 .Nm
839 won't be able to serve files inside that directory until a restart.
840 This restriction only applies to the root directories and not their
841 content.
842 .It
843 a %2F sequence is indistinguishable from a literal slash: this is not
844 RFC3986-compliant.
845 .It
846 a %00 sequence is treated as invalid character and thus rejected.
847 .El