1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
corgi is a CGI server.
[](https://github.com/fasterthanlime/free-of-syn)
corgi listens on port 26744 by default.
`/etc/corgi.conf`
```
Server
Port 26744
StatsDb /var/corgi/stats.db
Script <path-to-cgi-script>
Match
Regex <regular-expression>
Script <path-to-cgi-script>
Environment
HTTP_HOST <hostname>
ENV_KEY <some-env-value>
```
See [corgi.conf](corgi.conf) for the configuration I use with my cgit instance.
Scripts are tried in order, looking for one that matches. If none match,
the first script is ran.
Sets the following environmental variables for the CGI script, many following [RFC 3875][rfc]:
- **`GATEWAY_INTERFACE`** to the fixed value `CGI/1.1`
- **`PATH_INFO`** to the HTTP path the client requested
- **`QUERY_STRING`** to the query part of the URI
- **`REMOTE_ADDR`** is the `Forwarded-For` header, maybe prefixed with
an `X-`, or the client address if that header is not set
- **`REQUEST_METHOD`** to the HTTP request method
- **`SCRIPT_NAME`** is set to the path specified in the config
- **`SERVER_NAME`** is set to the HTTP host header
- **`SERVER_PORT`** is the port that corgi is running on
- **`SERVER_PROTOCOL`** is the HTTP version string that the request came in on
- **`SERVER_SOFTWARE`** is `corgi/1.0` where `1.0` is the current version number
Additionally, corgi will set environment variables for the HTTP request headers.
They will be uppercased and hyphens replaced with underscores.
Any environmental variable may be overridden if it is set in the
configuration file, except the `CONTENT_LENGTH` envar.
[rfc]: https://datatracker.ietf.org/doc/html/rfc3875
corgi has a cgi module system as an alternate for spawning a new process
on every request. it creates a new thread, loads a dynamic library into
it, and executes functions from that library. since it's a function,
corgi doesn't need to send all the data on standard input but can instead
pass a cleaner, more structured struct with the headers and body still
separate from one another.
the module system is designed to, hopefully, allow more efficient cgi
scripts than the conventional approach while still having the same
flexibility. it has not yet been benchmarked.
see [smalldog](smalldog/README.md) for more details on how it works.
|