💾 Archived View for hedy.tilde.cafe › spsrv captured on 2021-11-30 at 20:18:30. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
A static spartan server with many features:
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->
- [install](#install)
- [with `go get`](#with-go-get)
- [or just build it yourself](#or-just-build-it-yourself)
- [otherwise...](#otherwise)
- [configuration](#configuration)
- [config options](#config-options)
- [CLI](#cli)
- [CGI](#cgi)
- [todo](#todo)
<!-- markdown-toc end -->
you have two options for now:
first, you need to have go installed and have a folder `~/go` with `$GOPATH` pointing to it.
go get git.sr.ht/~hedy/spsrv
there will be a binary at `~/go/bin/` with the source code at `~/go/src/`
feel free to move the binary somewhere else like `/usr/sbin/`
run `git clone https://git.sr.ht/~hedy/spsrv` from any directory and `cd spsrv`
make sure you have go installed and working.
go build
when it finishes, the binary will be in the current directory.
If you don't have/want go installed, you can contact me, and if you're lucky, I have the same OS as you and you can use my compiled binary (lol). I'll eventually have automated uploads of binaries for various architectures for each release in the future.
The default config file location is `/etc/spsrv.conf` you can specify your own path by running spsrv like
spsrv -c /path/to/file.conf
You don't need a config file to have spsrv running, it will just use the default values.
Note that the options are case insensitive.
Here are the config options and their default values
You can override values in config file if you supply then from the command line:
Usage: spsrv [ [ -c <path> -h <hostname> -p <port> -d <path> ] | --help ] -c, --config string Path to config file -d, --dir string Root content directory -h, --hostname string Hostname -p, --port int Port to listen to`)
Note that you *cannot* set the hostname or the dir path to `,` because spsrv uses that to check whether you provided an option. You can't set port to `0` either, sorry, this limitation comes with the advantage of being able to override config values from the command line.
There are no arguments wanted when running spsrv, only options as listed above :)
The following environment values are set for CGI scripts:
GATEWAY_INTERFACE # CGI/1.1 REMOTE_ADDR # Remote address SCRIPT_PATH # (Relative) path of the CGI script SERVER_SOFTWARE # SPSRV SERVER_PROTOCOL # SPARTAN REQUEST_METHOD # Set to nothing SERVER_PORT # Port SERVER_NAME # Hostname DATA_LENGTH # Input data length
The data block, if any, will be piped as stdin to the CGI process.
Keep in mind that CGI scripts (as of now) are run by the same user as the server process, hence it is generally dangerous for allowing users to have their own CGI scripts. See configuration section for more details.
- [x] /folder to /folder/ redirects - [x] directory listing - [ ] logging to files - [x] ~user directories - [x] refactor working dir part - [x] config - [ ] status meta - [x] user homedir - [x] hostname, port - [x] public dir - [ ] dirlist title - [ ] userdir slug - [ ] redirects - [x] CGI - [x] pipe data block - [ ] user cgi config and change uid to user - [ ] regex in cgi paths