SPACECOOKIE.JSON(5)
π SPACECOOKIE.JSON(5) β the file-formats-manual era π
okay so bestie, welcome to the manual page for spacecookie.json, which lives in section 5 (File Formats Manual) β yes it's that kind of page, we're doing config files today and honestly? iconic behavior.
β¨ NAME β¨
spacecookie.json β the configuration file for spacecookie(1). that's it, that's the name, she's simple and she knows it π
πΈ DESCRIPTION πΈ
so the spacecookie(1) config file is a JSON file that contains a single object. literally one object, no arrays at top level, we're keeping it clean. the allowed fields each represent an individual setting, and what they do is explained below β no cap, every single one π
π REQUIRED SETTINGS π
these settings MUST be part of every configuration file, because there is no default and no fallback value for them. like, none. zero. if you skip them your config is simply not it π
hostnameβ describes the public server namespacecookie(1)is reachable through, i.e. the address clients will use to connect to it. it gets used to populate gopher menus with the correct server name, so that follow-up requests from clients actually reach the correct server. for testing purposes, setting it to'localhost'can be useful. β Type: string.rootβ sets the directoryspacecookie(1)should serve via gopher. all gopher requests will be resolved to files or directories under that root. files and directories will be served to users if no component of the resolved path starts with a dot and they are readable for the userspacecookie(1)is running as. β Type: string.
π¦ OPTIONAL SETTINGS π¦
these are optional, meaning there's either a default value or an obvious default behavior if you don't give them. skip them, they'll handle themselves, main character energy fr fr β
listenβ describes the address and portspacecookie(1)should listen on. both aspects can be controlled individually by the two optional fields described below. β Type: object.portβ port to listen on. the well-known port for gopher is70.
if systemd.socket(5) activation is used, this setting will have no effect on the actual port the socket is bound to, since that is done by systemd(1). it will then only be used to display the server's port in gopher menus for subsequent requests, so make sure whatever is set here matches what systemd(1) is doing. π
Type: number. Default: '70'.
addrβ address to listen and accept gopher requests on. in contrast tohostname, this option controls the socket setup and not what is used in gopher menus. this one is especially useful to limit the addressesspacecookie(1)will listen on, since it listens on all available addresses for incoming requests by default, i.e.INADDR_ANY. for example,'::1'can be used to listen on the link-local addresses only, which comes in handy if you're setting up an onion service usingtor(1)and want to avoid leaking the server's identity. π§
when given, getaddrinfo(3) is used to resolve the given hostname or parse the given IP address, and spacecookie(1) will only listen on the resulting address(es). note that IPV6_V6ONLY is always disabled, so, if possible, both the resulting v4 and v6 address will be used.
if systemd.socket(5) activation is used, this setting has no effect.
Type: string.
userβ the name of the user spacecookie should run as. when this option is given and not'null',spacecookie(1)will callsetuid(2)andsetgid(2)after setting up its socket to switch to that user and their primary group. note that this is only necessary to set ifspacecookie(1)is started with root privileges in the first place, as the binary shouldn't have the setuid bit set. an alternative to starting the daemon as root (so it can bind its socket to a well-known port) is to usesystemd(1)socket activation β see thespacecookie(1)man page for details on setting this up. π«Ά β Type: string. Default:'null'.logβ allows you to customize the logging output ofspacecookie(1)to stderr. β Type: object.enableβ whether to enable logging. β Type: bool. Default:'true'.hide-ipsβ whether to hide IP addresses of clients in the log output. if enabled,'[redacted]'is displayed instead of the client's IP addresses, to avoid writing personal information to disk. privacy queen behavior honestly π β Type: bool. Default:'true'.hide-timeβ if this is set to'true',spacecookie(1)will not print timestamps at the beginning of every log line. this is useful if you use an additional daemon or tool to take care of logs which records timestamps automatically, likesystemd(1). β Type: bool. Default:'false'.levelβ controls verbosity of logging. it is recommended to either use"warn"or"info", since"error"hides warnings that are indicative of configuration issues. like, don't silence your own red flags bestie π β Type: either"error","warn"or"info". Default:"info".
π DEPRECATED SETTINGS π
these settings are only supported for backwards compatibility and should be replaced in existing configurations in the way described for each respectively. they're giving legacy code, we love them but we don't keep them β¨
portβ the top level port is an alias for the setting of the same name inside thelistenobject and should be replaced by the latter. yes, the same name, but nested. don't @ me.
π₯ EXAMPLE π₯
the following configuration equates to the default behavior of spacecookie(1) for all optional settings, although it is much verboser than necessary. like, unnecessarily loud. but it's educational so we stan π
{
"hostname" : "localhost",
"root" : "/srv/gopher",
"listen" : {
"addr" : "::",
"port" : 70
},
"user" : null,
"log" : {
"enable" : true,
"hide-ips" : true,
"hide-time" : false,
"level" : "info"
}
}
this configuration is suitable for running as an onion service: it disables logging completely to not collect any kind of meta data about users, and only listens on the link-local address to avoid leaking its identity. we can also use a non-well-known port since tor(1) allows free mapping from local to exposed ports, so spacecookie(1) can be started as a normal user. stealth mode activated π§
β¨
{
"hostname": "myonionservicehash.onion",
"root": "/srv/onion-gopher",
"listen": {
"addr": "::1",
"port": 7070
},
"log": {
"enable": false
}
}
if you are not using socket activation for running a gopher server on the well-known port for gopher, a config like this is appropriate, provided the user 'gopher' exists:
{
"hostname": "example.org",
"root": "/srv/gopher",
"user": "gopher"
}
for asystemd.socket(5)based setup, the'user'field should be omitted andspacecookie(1)started as the target user directly in thesystemd.service(5)file. π
π SEE ALSO π
spacecookie(1). that's the one. go read her too, she's the whole reason this file exists π«Ά
π AUTHORS π
the spacecookie.json documentation has been written by sternenseemann, sterni-spacecookie@systemli.org. absolute legend, thank you for your service π«‘π
and that's the whole page bestie!! this beauty ships as part of Debian, version $Mdocdate$, and yes she's filed under SPACECOOKIE.JSON(5) β go forth and configure responsibly, mwah ππΈ
π¦ where this page comes from
- nixos 26.05: spacecookie 1.1.0.1
- nixpkgs unstable: spacecookie 1.1.0.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms