-- Leo's gemini proxy
-- Connecting to thfr.info:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini;lang=en
> Update 2022-02-02: added tic-tac-toe.cgi; see below
I have been running vger on my OpenBSD server for a while and am pretty happy with it. It is written by OpenBSD developer solene@ and has the right combination of small codebase and use of security mitigations like unveil(2).
Last week, I came across a capsule that features a "like button" on its pages:
This got me curious about CGI with gemini. After asking on tilde.chat #gemini IRC, tomasino gave me some hints, including from his video on the topic:
First I thought I would need a different gemini server to do that, but then I saw that vger supports CGI via the `-c` flag. I created a directory `cgi-bin` and passed it to vger in inetd.conf which now looks like this:
127.0.0.1:11965 stream tcp nowait gemini_user /usr/local/bin/vger vger -i -v -d /var/gemini/ -c /var/gemini/thfr.info/cgi-bin
I started with my first hello-world script, based on what I had previously made for HTTP CGI. I quickly realized that instead of "Content-type text/plain" I had to send "20 text/gemini" as the header, followed by CRLF (20 indicates success in gemini specification).
That worked, so I set out to make 2 other, more interactive CGI examples. Here is a list of the (fairly simple) early CGI applications:
Popcat is based on:
And here the links to view or download the source code of these 3 examples:
Make popcat.cgi prettier, add counter, and run statistics by country like the original.
A tic-tac-toe clone - Update: Done!
Potentially a chess game - could be for 2 players, and gemini input via status code 10 could be used to send the next move.
Can vger handle multiple CGI directories, mainly for virtualhost use?
Can vger pass the REMOTE_ADDR to the script so that this can be used for statistics?
Can CGI requests be run through a chroot to not allow other system access?
-- Response ended
-- Page fetched on Sun May 5 02:52:30 2024