KiwiIRC is an IRC web client and webircgateway acts as its helpful websocket gateway (it is written in Go). The config is rather easy-peasy on Caddy’s side. My main source of confusion was rather the .sock file ownership. The important thing is to have the .sock file in a directory owned by the web user (777 perms for the .sock do not help).
Pre-built binaries are available. In the .zip you have a binary called “kiwiirc” which is webircgateway and config.conf.example is its config file. The config file for KiwiIRC client is www/static/config.json in the .zip. Of course you can also do your own builds, the process is rather straightforward and explained in the readmes found in the repositories.
I placed the webircgateway executable and config to /var/www which is owned by my web user (http). In the config I have:
# Example unix socket server
[server.3]
bind = unix:/var/www/webircgateway.sock
bind_mode = 0644
[upstream.1]
hostname = "irc.freenode.net"
port = 6697
tls = true
Also, in the [reverse_proxies] section I added the IP of my server in CIDR format.
My Caddy rule is:
proxy /webirc unix:/var/www/webircgateway.sock {
websocket
transparent
}
In the KiwiIRC config.json file I have (the path /webirc/kiwiirc is hardcoded in webircgateway):
"kiwiServer": "https://www.mysite.org/webirc/kiwiirc/",
and
"startupOptions" : {
"server": "irc.freenode.net",
"port": 6697,
"tls": true,
"channel": "#kiwiirc-default",
"nick": "kiwi-n?"
},
I created a systemd unit for webircgateway:
[Unit]
Description=Websocket gateway to IRC networks
Documentation=https://github.com/kiwiirc/webircgateway
After=network.target
[Service]
User=http
Group=http
ExecStart=/var/www/webircgateway/webircgateway --config=/var/www/webircgateway/config.conf
ExecReload=/usr/bin/kill -USR1 $MAINPID
LimitNOFILE=1048576
[Install]
WantedBy=multi-user.target