No description
  • Go 96.2%
  • Makefile 3.8%
Find a file
Lukas 4ae5f17363
Some checks failed
REUSE Compliance Check / REUSE Compliance (push) Has been cancelled
Release Please / release (push) Has been cancelled
feat: make log level configurable
2025-05-26 20:56:29 +02:00
.github/workflows chore: bump golang version to 1.24 2025-05-26 19:20:19 +02:00
LICENSES reuse compliant 2025-05-25 23:26:17 +02:00
.gitignore reuse compliant 2025-05-25 23:26:17 +02:00
cgi.go feat: add support for FCGI_CHDIR 2025-05-26 19:20:19 +02:00
cgi_test.go chore: move testing files around 2025-05-26 19:20:19 +02:00
CHANGELOG.md chore(main): release 1.2.0 2025-05-26 18:41:49 +00:00
fcgi_handler.go reuse compliant 2025-05-25 23:26:17 +02:00
fcgi_handler_test.go reuse compliant 2025-05-25 23:26:17 +02:00
go.mod reuse compliant 2025-05-25 23:26:17 +02:00
go.sum add some tests 2025-05-25 22:48:32 +02:00
go.sum.license reuse compliant 2025-05-25 23:26:17 +02:00
LICENSE Initial commit 2025-05-25 17:49:31 +02:00
listener.go feat: filter environment which gets inherited 2025-05-26 19:20:19 +02:00
logger.go feat: make log level configurable 2025-05-26 20:56:29 +02:00
main.go feat: make log level configurable 2025-05-26 20:56:29 +02:00
Makefile reuse compliant 2025-05-25 23:26:17 +02:00
README.md feat: add support for FCGI_CHDIR 2025-05-26 19:20:19 +02:00
responder.go feat: normal cgi way of parsing http headers in the reply 2025-05-26 20:41:24 +02:00

fcgiwrap_go

fcgiwrap_go is a re-implementation of the original fcgiwrap tool. Written in golang the codebase is considerably smaller and the server structure fits quite well into the golang idioms. Also the native fcgi library in the stdlib of go offers a nice support in the golang ecosystem (without having to implement some state-machine in order to parse the response).

The main driver for re-implementing the fcgiwrap tool was to be able to stop the server if for some time no new requests are made. This is supposed to save resources, as the process does not need to be around forever.

With most systems using systemd nowadays, you might want to start this tool by a systemd service unit which in turn is started by a systemd socket unit. This way the fcgiwrap_go tool only is activated after a request came in and handles the request. Then (optionally) it waits some time for new requests, deactivates again and is started only if needed afterwards.

The commandline arguments are quite similar to those of fcgiwrap. But see -h for a full (up-to-date) explanation.

Environment

Like the original fcgiwrap, this tool evaluates the following environment variables set in the fcgi request:

  • DOCUMENT_ROOT: directory which the script resides in
  • SCRIPT_NAME: name of the actual executable
  • SCRIPT_FILENAME: complete path to CGI script. When set, overrides DOCUMENT_ROOT and SCRIPT_NAME

When SCRIPT_FILENAME is not set, the executable being executed will be DOCUMENT_ROOT/SCRIPT_NAME.

Testing

For adhoc testing, you can use

./fcgiwrap_go -s unix:./test -t 10
SCRIPT_FILENAME=$PWD/test.sh REQUEST_METHOD=GET SERVER_PROTOCOL=HTTP/1.1 cgi-fcgi -connect ./test $PWD/test.sh

Differences

  • No handling/setting of the PATH_INFO environmenr variable
  • For security reasons, symlinks generally are forbidden regarding executing scripts
  • Also SCRIPT_FILENAME (and FCGI_CHDIR if used) needs to be an absolute path