From 579a6f157279f4fe6c8cc900568f74ccd5bf4964 Mon Sep 17 00:00:00 2001 From: Nathan Fisher Date: Thu, 16 Jun 2022 23:07:56 -0400 Subject: [PATCH] Update agis page, improve Makefile --- Makefile | 9 ++++++--- content/software/agis.gmi | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index d4ffbe9..98273d2 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,13 @@ build: zond build capsule.tar: - cd public && tar cvf ../capsule.tar * + cd public && tar cf ../capsule.tar * upload: capsule.tar scp capsule.tar gimli:/home/nathan/capsule.tar - ssh gimli tar xvf capsule.tar -C /srv/gemini + ssh gimli tar xf capsule.tar -C /srv/gemini -.PHONY: all build upload +clean: + rm -rf capsule.tar public + +.PHONY: all build clean upload diff --git a/content/software/agis.gmi b/content/software/agis.gmi index 369dc11..c99ea2c 100644 --- a/content/software/agis.gmi +++ b/content/software/agis.gmi @@ -58,6 +58,7 @@ Each directive is looked up via a key, which is the path which it applies to. * Alias - Serves files requested for this path from a different path. This is handled by the server transparently to the client. * Redirect - Any request for this specific path will be sent a redirect to the new location, to be handled by the client. * Cgi - Any requests under this directory will be passed to the cgi program which is the direct child of the directory. If the Cgi directive is given the path '/cgi-bin/', and a client requests '/cgi-bin/foo/bar/baz.gmi?fizzbuzz=true' then the program located at '/server-root/cgi-bin/foo' will be run and given the rest of the path and query as environment variables. This implementation is a subset of CGI 1.1 with http specific environment vars removed. +- ScriptAlias(path) - Any requests under this path will be interpreted via the CGI program specified by . The is given as an absolute path, with the path to the server root stripped from it. Thus, if the server root is `/srv/spartan` and the CGI program resides at `/srv/spartan/cgi-bin/hello`, then would be given as `/cgi-bin/hello`. The default configuration runs the server as user 'agis' and group 'agis'. You will need to create that user and group on your system or Agis will not run. ``` @@ -67,3 +68,24 @@ useradd -r -s /sbin/nologin agis If you are running Linux with Systemd init, there is a unit file included in the conf/ subdirectory. It can be copied into /etc/systemd/system and then started and stopped like any other service. If you are on a Linux system that does not use systemd, or bsd, it should be straitforward to write your own init script. The default location for the configuration file is `/etc/agis/config.ron` but can be overridden on the command line with the `-c` or `--config` flag. This is currently the only command line option which is supported, making startup quite straightforward. + +## CGI +A CGI program can be written in any language and receives it's input via environment variables. The program's output should present it's mime type in plain text, followed by a carriage return and newline, and then any data which is representable via a sequence of u8 bytes. This can be plain text but does not have to be. +### CGI environment vars +``` +Var | Meaning +--------------- | --------------------------------- +DOCUMENT_ROOT | The root directory of your server +QUERY_STRING | The query string +REMOTE_ADDR | The IP address of the client +REQUEST_URI | The interpreted pathname of the requested document or CGI (relative to the document root) +SCRIPT_FILENAME | The full pathname of the current CGI +SCRIPT_NAME | The interpreted pathname of the current CGI (relative to the document root) +SERVER_NAME | Your server's fully qualified domain name (e.g. www.cgi101.com) +SERVER_PORT | The port number your server is listening on +SERVER_SOFTWARE | The server software you're using +REQUEST_BODY | The path to a temporary file containing any content uploaded to the server +``` + +## ScriptAlias +The ScriptAlias directive allows passing requests to a CGI program without the cgi-bin directory or program name appearing in the url. In this way, dynamic content can be served without revealing to the client that a CGI program is being run or what the nature of that program is. This might be desireable if, for instance, one is using php scripting and doesn't wish to make that readily known to potential attackers.