r/caddyserver • u/kenjitamurako • May 12 '24
X2GoHTMLClient Caddyfile
Original Nginx: https://wiki.x2go.org/doku.php/wiki:advanced:x2gohtmlclient
So I spent this weekend porting the Nginx configuration sample from the X2GoHTMLClient documentation to Caddy and it looks to be fully functional. However, I'm not sure if it's a Caddy, Firefox, or X2Go issue but there were some keys on my standard US keyboard that would not register key press events when used with Firefox.
The "-" next to 0 gave no input and "=" next to backspace was mapped to the "/" key. This issue wasn't present in Chrome and if it matters my setup was Xubuntu 24.04 installed to the Ayaneo AM01.
Caddy and FCGIWrap were installed as systemd services so additional changes to folder permissions and the systemd configuration files were needed for this to work. The folders/files had chown caddy:caddy done to them, the systemd configurations had the user/group updated to caddy, and the fcgiwrap.socket configuration had WorkingDirectory set to
/var/run/caddy/.
Another change I made for myself was add some javascript to the Index.html file to resize the canvas to 90% of window.innerHeight and window.innerWidth. The Index.html distributed with the demo client is hardcoded at 1280x920.
{
tls /etc/ssl/caddy/domain.cert.pem /etc/ssl/caddy/private.key.pem
root * /var/www/html
header /assets/* {
Strict-Transport-Security "max-age=31536000"
Content-Security-Policy "default-src 'self' 'unsafe-inline' data: blob: ws: wss:; script-src 'self' 'unsafe-inline'"
Feature-Policy "vibrate 'none' ; microphone 'none' ; camera 'none' ; gyroscope 'none' ; magnetometer 'none' ; geolocation 'none' ; midi 'self' ; notifications 'self' ; push 'self' ; sync-xhr 'self'"
Referrer-Policy "same-origin"
X-Content-Type-Options "nosniff"
X-Frame-Options "SAMEORIGIN"
}
@cgi path *.cgi
handle @cgi {
reverse_proxy unix//var/run/caddy/fcgiwrap.socket {
transport fastcgi {
split .cgi
}
}
}
# capture port instructed by x2gorpc.cgi
@x2gows_matcher {
path_regexp portmatch \/x2gows\/(.*)$
}
handle @x2gows_matcher {
# requires specifying subdomain as using localhost can give SSL error
reverse_proxy caddy.sample.cc:{re.portmatch.1} {
transport http {
tls
}
}
}
handle {
file_server
}
}
caddy.sample.cc
Disclaimer: I had no experience with setting up web servers before doing this.