GMID.CONF(5)
π NAME π
gmid.conf(5) β from the File Formats Manual, bestie β gmid.conf is the gmid Gemini server configuration file. π
β¨ DESCRIPTION β¨
Okay so gmid.conf is literally the configuration file format for the gmid(8) Gemini server. It's giving four sections, bestie:
- Macros β user-defined variables may be defined and used later, simplifying the configuration file. π§
- Global Options β global settings for
gmid(8). π - Types β media types and extensions. π
- Servers β virtual hosts definition. π
Inside those sections, empty lines are ignored, and comments can be put anywhere in the file using a hash mark (#) and extend to the end of the current line. A boolean is either the symbol on or off. A string is a sequence of characters wrapped in double quotes, "like this". Multiple strings one next to the other are joined into a single string:
# equivalent to "temporary-failure"
block return 40 "temporary" "-" "failure"
Furthermore, quoting is necessary only when a string needs to contain special characters (like spaces or punctuation), something that looks like a number or a reserved keyword. The last example could have been written also as:
block return 40 temporary "-" failure
Strict ordering of the sections is not enforced, so it's possible to mix macros, options and server blocks β slay, no cap. However, defining all the server blocks after the macros and the global options is recommended, periodt. Newlines are often optional, except around top-level instructions, and semicolons (;) can also be optionally used to separate options.
Additional configuration files can be included with the include keyword, for example:
include "/etc/gmid.conf.local"
Obsessed. π
π§ Macros π§
Macros can be defined that will later be expanded in context. Macro names must start with a letter, digit or underscore and may contain any of those characters. Macro names may not be reserved words. Macros are not expanded inside quotes. Not even a little.
Two kinds of macros are supported: variable-like and proper macros. When a macro is invoked with a $ before its name, it's expanded as a string, whereas when it's invoked with a @, it's expanded in-place.
For example:
ext_ip = "10.0.0.1"
dir = "/var/gemini"
certdir = "/etc/keys"
common = "lang it; auto index on"
server "foo" {
listen on $ext_ip
root $dir "/foo" # "/var/gemini/foo"
cert $certdir "/foo.pem" # "/etc/keys/foo.pem"
key $certdir "/foo.key" # "/etc/keys/foo.key"
@common
}
This example ate, honestly. π«Ά
π Global Options π
chroot pathβchroot(2)the process to the givenpath. ngl, the daemon has to be run with root privileges and thus the optionuserneeds to be provided too, so privileges can be dropped afterwards. The way that paths work here: all the paths in the configuration file are relative to the chroot directory, except for thecert,keyandocsppaths. Defaults to the user home directory, if provided.log optionsβ Specify logging options. Multiple options may be provided within curly braces. The available options are as follows:access fileβ Log the requests tofile. The path is relative to the chroot.style styleβ Set the logging style, defaults tolegacy. The style can be one of:commonβ Attempt to be compatible with the default Apache httpd log format. Each line is formatted as follows: the matching host name, the remote IP address, one dash-, Common Name of the client certificate (if provided,'-'otherwise), the timestamp of the request, the request URI wrapped in double quotes, the response code and the size of the response.combinedβ Attempt to be compatible with the default nginx log format. Each line is formatted as follows: the remote IP address, one dash-, Common Name of the client certificate (if provided,'-'otherwise), the timestamp wrapped in square brackets, the request URI wrapped in double quotes, the response code, the size of the response, a dash wrapped in double quotes and"". The strangeness of these two last fields is because Gemini doesn't have the notion of theRefererheader nor theUser-agent.legacyβ Each line is formatted as follows: the remote IP address and port, theGETkeyword, the request URI, the response code and meta.
syslog [off]β Log to syslog. It is enabled by default, use theoffargument to disable.syslog facility facilityβ Log tosyslog(3)using specifiedfacility. Available facilities are as follows:daemon,ftp,local0throughlocal7anduser. These are case insensitive and can be prefixed withLOG_. Not all level may be available on all operating systems. The default facility isLOG_DAEMON. iykyk.
prefork numberβ Run the specified number of server processes. This increases the performance and prevents delays when connecting to a server.gmid(8)runs 3 server processes by default. The maximum number allowed is 16.protocols stringβ Specify the TLS protocols to enable. Refer totls_config_parse_protocols(3)for the valid protocol string values. By default, bothTLSv1.3andTLSv1.2are enabled. Use"tlsv1.3"to enable onlyTLSv1.3.user stringβ Run the daemon as the given user. Mandatory if thechrootoption is used.
π Servers π
Every virtual host is defined by a server block:
server hostname {...}
Match the server name using shell globbing rules. It can be an explicit name, www.example.com, or a name including wildcards, *.example.com.
Followed by a block of options that is enclosed in curly brackets:
alias nameβ Specify an additional alias name for this server.auto index boolβ If no index file is found, automatically generate a directory listing. Disabled by default. vibe check: off unless you say otherwise, no cap.block [return code [meta]]β Send a reply and close the connection; by defaultcodeis40andmetais"temporary failure". Ifcodeis in the3xrange, thenmetais mandatory. Insidemeta, the following special sequences are supported:%%β is replaced with a single%.%pβ is replaced with the request path.%qβ is replaced with the query string of the request.%Pβ is replaced with the server port.%Nβ is replaced with the server name.
cert fileβ Path to the certificate to use for this server.fileshould contain a PEM encoded certificate. This option is mandatory. Main character energy, fr fr.default type stringβ Set the default media type that is used if the media type for a specified extension is not found. If not specified, the default type is set to"application/octet-stream".fastcgi optionβ Enable FastCGI instead of serving files. Multiple options may be specified within curly braces. Valid options are:param name = valueβ Set the paramnametovalue.socket [tcp] socket [port port]β Thesocketcan either be a UNIX-domain socket or a TCP socket. If the FastCGI application is listening on a UNIX domain socket,socketis a local path name within thechroot(2)root directory ofgmid(8). Otherwise, thetcpkeyword must be provided andsocketis interpreted as a hostname or an IP address.portcan be either a port number or the name of a service enclosed in double quotes. If not specified defaults to9000.strip numberβ Stripnumberleading path components from the request URL before splitting it inSCRIPT_NAMEandPATH_INFO.
The FastCGI handler will be given the following variables by default:
GEMINI_URL_PATHβ Full path of the request.GEMINI_SEARCH_STRINGβ The decodedQUERY_STRINGif defined in the request and if it doesn't contain any unencoded=characters, otherwise unset.GATEWAY_INTERFACEβ"CGI/1.1".AUTH_TYPEβ The string"Certificate"if the client used a certificate, otherwise unset.PATH_INFOβ The portion of the requested path that is derived from the IRI path hierarchy followingSCRIPT_NAME. Can be unset.PATH_TRANSLATEDβ Present if and only ifPATH_INFOis set. It represents the translation of thePATH_INFO. gmid builds this by appending thePATH_INFOto the virtual host directory root.QUERY_STRINGβ The URL-encoded search or parameter string.REMOTE_ADDR,REMOTE_HOSTβ Textual representation of the client IP.REQUEST_METHODβ This is present only forRFC3875 (CGI)compliance. It's always set to"GET".
okay so the CGI environment variables, bestie β gmid hands these to your script and they're lowkey essential π
SCRIPT_NAMEβ the virtual URI path to the script. since it's impossible to determine the correctSCRIPT_NAMEprogrammatically in all cases, gmid assumes it's the empty string. it is recommended to manually specify this parameter when serving a sub-tree of a virtual host via FastCGI πSERVER_NAMEβ the name of the server.SERVER_PORTβ the port the server is listening on.SERVER_PROTOCOLβGEMINI.SERVER_SOFTWAREβ the name and version of the server, i.e.gmid/2.1.1.REMOTE_USERβ the subject of the client certificate if provided, otherwise unset.TLS_CLIENT_ISSUERβ the issuer of the client certificate if provided, otherwise unset.TLS_CLIENT_HASHβ the hash of the client certificate if provided, otherwise unset. the format isALGO:HASH.TLS_VERSIONβ the TLS version negotiated with the peer.TLS_CIPHERβ the cipher suite negotiated with the peer.TLS_CIPHER_STRENGTHβ the strength in bits for the symmetric cipher that is being used with the peer.TLS_CLIENT_NOT_AFTERβ the time corresponding to the end of the validity period of the peer certificate in the ISO 8601 format (e.g.2021-02-07T20:17:41Z).TLS_CLIENT_NOT_BEFOREβ the time corresponding to the start of the validity period of the peer certificate in the ISO 8601 format.
fastcgi offβ disable FastCGI handling in the current location π«index stringβ set the directory index file. if not specified, it defaults toindex.gmi.key fileβ specify the private key to use for this server.fileshould contain a PEM encoded private key. this option is mandatory π₯lang stringβ specify the language tag for thetext/geminicontent served. if not specified, nolangparameter will be added in the response.listen on address [port number] [proxy-v1]β set the listen address and port, which defaults to1965. this statement can be specified multiple times. ifaddressis*thengmid(8)will listen on all IPv4 and IPv6 addresses.0.0.0.0can be used to listen on all IPv4 addresses and::on all IPv6 addresses. ifproxy-v1is specified, then connections speaking the proxy protocol v1 are expected on this listener. if multiplelistendirectives share the same address and port, then all of them must have or lackproxy-v1β οΈlocation path {...}β specify server configuration rules for a specific location.pathargument will be matched against the request path with shell globbing rules. in case of multiplelocationstatements in the same context, the first matching location will be put into effect and the later ones ignored. therefore it is advisable to match for more specific paths first and for generic ones later on. alocationsection may include most of the server configuration rules exceptalias,cert,key,listen,locationandproxy.log boolβ enable or disable the logging for the current server or location block.ocsp fileβ specify an OCSP response to be stapled during TLS handshakes with this server. thefileshould contain a DER-format OCSP response retrieved from an OCSP server for the cert in use. if the OCSP response infileis empty, OCSP stapling will not be used. the default is to not use OCSP stapling.proxy [proto name] [for-host host [port port]] {...}β set up a reverse proxy. the optional matching rulesprotoandfor-hostcan be used to enable proxying only for protocols matchingname(geminiby default) and/or whose request IRI matcheshostandport(1965by default). matching happens using shell globbing rules. in case of multiple matchingproxyblocks in the same context, the first matching proxy will be put into effect and the later ones ignored. valid options are:cert fileβ specify the client certificate to use when making requests.key fileβ specify the client certificate key to use when making requests.protocols stringβ specify the TLS protocols allowed when making remote requests. refer to thetls_config_parse_protocols(3)function for the valid protocol string values. by default, bothTLSv1.2andTLSv1.3are enabled.proxy-v1β use the proxy protocol v1. if supported by the remote server, this is useful to propagate the information about the originating IP address and port.relay-to host [port port]β relay the request to the givenhostat the givenport,1965by default. this is the only mandatory option in a proxy block π₯require client ca fileβ allow the proxying only from clients that provide a certificate signed by the CA certificate infile.sni hostnameβ use the givenhostnameinstead of the one extracted from therelay-torule for the TLS handshake with the proxied gemini server.use-tls boolβ specify whether to use TLS when connecting to the proxied host. enabled by default.verifyname boolβ enable or disable the TLS server name verification. enabled by default.
root directoryβ specify the root directory for this server (alas, the current βdocument rootβ π). it's relative to the chroot if enabled.require client ca pathβ allow requests only from clients that provide a certificate signed by the CA certificate inpath. it needs to be a PEM-encoded certificate and it's not relative to the chroot.strip numberβ stripnumbercomponents from the beginning of the path before doing a lookup in the root directory. it's also considered for themetaparameter in the scope of ablock return.
β¨ Types β¨
the types section must include one or more lines of the following syntax, enclosed in curly brances (yes bestie, curly brances π):
type/subtype name [name ...]β set the media type and subtype to the specified extensionname. one or more names can be specified per line. each line may end with an optional semicolon.include fileβ include types definition from an external file, for example/usr/share/misc/mime.types.
by default gmid uses the following mapping if no types block is defined:
application/pdf pdf
image/gif gif
image/jpeg jpg jpeg
image/png png
image/svg+xml svg
text/gemini gemini gmi
text/markdown markdown md
text/x-patch diff patch
text/xml xml
as an exception, gmid uses the MIME type text/gemini for file extensions gemini or gmi if no mapping was found.
πΈ EXAMPLES πΈ
here's a config for a site that enables only TLSv1.3, adds the MIME types mapping from /usr/share/misc/mime.types, and defines two virtual hosts:
protocols "tlsv1.3"
types {
include "/usr/share/misc/mime.types"
}
server "example.com" {
listen on * port 1965
cert "/etc/ssl/example.com.pem"
key "/etc/ssl/private/example.com.key"
root "/var/gemini/example.com"
}
server "example.it" {
listen on * port 1965
cert "/etc/ssl/example.it.pem"
key "/etc/ssl/private/example.it.key"
root "/var/gemini/example.it"
# set the language for text/gemini files
lang "it"
}
this example shows how to enable the chroot and use a location rule:
chroot "/var/gemini"
user "_gmid"
server "example.com" {
listen on * port 1965
# absolute paths:
cert "/etc/ssl/example.com.pem"
key "/etc/ssl/private/example.com.key"
# relative to the chroot:
root "/example.com"
location "/static/*" {
# load the following rules only for
# requests that matches "/static/*"
auto index on
index "index.gemini"
}
}
this example shows how to log requests to /var/gemini/logs/access.log when running in the /var/gemini chroot. the file will be created if it does not exist:
chroot "/var/gemini"
user "_gmid"
log {
access "/logs/access.log" # relative to the chroot
}
and this example shows how to set up a reverse proxy: all requests for example.com will be forwarded to 10.0.0.6 transparently. proxying establishes a new TLS connection, so any client-certificates used to connect to gmid(8) cannot be provided to the proxied server:
server "example.com" {
listen on * port 1965
cert "/etc/ssl/example.com.pem"
key "/etc/ssl/private/example.com.key"
proxy {
relay-to 10.0.0.6 port 1965
}
}
π₯ SEE ALSO π₯
gmid(8)slowcgi(8)
π AUTHORS π
the gmid program was written by Omar Polo <op@omarpolo.com>. periodt π
that's the whole page, bestie π«Ά β it's from Debian, dated August 25, 2024, and it's GMID.CONF(5) β¨
π¦ where this page comes from
- nixos 26.05: gmid 2.1.1
- nixpkgs unstable: gmid 2.1.1
- Copyright (c) 2022, 2023, 2024 Omar Polo <op@omarpolo.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms