Comment by 🚀 ingrix
I goofed the links, sorry. Try:
Sep 01 · 4 months ago
19 Later Comments ↓
That's more like it!
@ingrix, a CGI question.
My game currently has a compiled CGI executable and a bunch of .gmi and data files in the same directory. Is it possible to configure the server to work with that, or would I need to segregate CGI scripts to a separate directory?
@stack
You /should/ be able to do what you're asking. Specify your cgi script directly in the location block to change its behavior. Example
location /path/to/my/game/files {
action=file
...
}
location /path/to/my/game/files/game.exe {
action=cgi
...
}
I haven't tried that combination specifically, but if that doesn't work then let me know and I will patch it.
@ingrix,
unzipped the topmost libpxd, trid to 'make' but error:
./update_version.sh: 3: set: Illegal option -o pipefail make: *** [Makefile:28: include/libpxd/px_version.h] Error 2
@stack
I thought I fixed that issue. If you remove that line in update_version.sh it should work. Sorry for the inconvenience.
@ingrix, having trouble with configuration, getting unrecognized key location.
When specifying location=... is that an absolute file path or the url path?
How do docroot and chroot_dir interact? Is docroot a url path or file path? If file path, is it post-chroot?
Here is what I am trying to do:
File system:
home
stack
gemkeys
...pems
public_gemini
stack
game
cgi # a cgi file
...gmi_files
And the config (does not work)
drop_user=stack
drop_group=stack
host=...
listen_addr=any
port=1965
cert_file=gemkey/my.crt
key_file=gemkey/my.key
chroot_dir=/home/stack/public_gemini
docroot=/
#home/stack/public_gemini
#fails on next line!
location=/stack/game{
action = file
}
>/home/stack>polluxd -f polluxd.conf
error polluxd_config.c: 152: polluxd.conf line 13: unrecognized key location
error polluxd.c: 111: could not update configuration from file
@stack
Location blocks should be specified as absolute paths and are matched against the request path. The block specification should not have '=' between 'location' and the directory, i.e. you want:
location /stack/game { <- no =
'docroot' is prepended to the request path to translate it into a filesystem path. It is considered post-chroot, as are most other values. The only pre-chroot values are the key/cert and log paths.
You may want to consider not specifying a chroot_dir and point 'docroot' at /home/stack/public_gemini for simplicity, first,then add a chroot once it's working.
@stack
Here's an off-the-cuff directory hierarchy and config file I put together based on what it seems like you're trying to do (though it runs out of /tmp instead of /home). Extract this into your /tmp and pass the enclosed polluxd-stack.conf to polluxd. You should be able to request gemini://localhost:1969/stack/game/cgi/stack.cgi and it'll print out the contents of one of the files in /tmp/stack/public_gemini/stack/game/
fyi this does not use a chroot
@ingrix: thanks, that works. I will do some more fixing tomorrow and do a trial launch.
@ingrix, a couple of quick questions:
Is the server intended to output ongoing activity to the invoking terminal and should be redirected to a log?
Is there a better way to terminate it other than looking up and killing it by process id?
Is there logging, btw?
@stack
Logging is written to stderr. You can redirect stderr to a log file with shell redirection which is perfectly fine, or you can use the logfile=... option in the global part of the config file which will open stderr to whatever file you specify there (that one is done pre-chroot, btw).
Looking up the PID and killing it is the way to go. If you send the main process (probably the lowest pid) a SIGHUP will do a clean shutdown, but you can also just kill all polluxd processes and it should work just fine. Forcible termination by other signals also shouldn't adversely affect anything in polluxd itself.
@ingrix: CGI is not getting REMOTE_USER!
I rely on the user name from the certificate!
GEMINI_URL=gemini://spell.ddns.net/games/env.cgi HOSTNAME=spell.ddns.net REMOTE_ADDR=71.247.220.174:52978 AUTH_TYPE=CERTIFICATE TLS_VERSION=TLSv1.3 PATH_TRANSLATED=/home/stack/public_gemini/games/env.cgi SERVER_SOFTWARE=libpxd/polluxd TLS_CIPHER=TLS_AES_256_GCM_SHA384 TLS_CLIENT_HASH=SERVER_PROTOCOL=gemini SERVER_ADDR=172.31.39.9:1965 TLS_CLIENT_PUBKEY_HASH= PWD=/ SCRIPT_NAME=/games/env.cgi SERVER_NAME=spell.ddns.net
@stack noted, polluxd doesn't extract that info yet. I'll put a patch together tonight.
Thank you!
out of curiosity, but what should be inside REMOTE_USER?
REMOTE_USER contains the name entered during the creation of the client certificate.
If you are curious, here is a cgi script that returns all environment variables sent by your client. Enable a certificate and see for yourself:
Unfortunately tilde team is down most of the time these days...
I was curious, cause most of my (user) certs simply are empty
I use the name in SpellBinding's top score board. If you play without a name, you will still be on the board without a name. Otherwise it does not affect gameplay.
Original Post
Which Gemini Server? — I am looking to run a Gemini server with CGI (and in the future something better that CGI) on an Amazon EC2 instance. GMID - unable to start. When started with -n, says configuration is ok. When started proper, just comes right back and does not seem to daemonize -- grepping for gmid yields nothing in processes. When doing 'make test', fails on almost everything -- localhost port 10965 seems not accessible -- even though I opened it. gmisrv -- cannot compile -- uses...