Here's how I got Foswiki working behind the
Caddy web server.
Caddy
The only thing in caddy's web root is a symlink for the
/pub
directory, which leads to the
pub
directory in my Foswiki directory. This way I don't have to worry about blocking access to Foswiki's data directory, code, etc., via the web server.
$ ls -l /caddy/www
lrwxrwxrwx 1 root root 22 Nov 20 12:22 pub -> ../../foswiki/wiki/pub
Caddy is configured as follows:
$ cat /caddy/Caddyfile
:443 {
log stdout
errors
tls self_signed
# Deal with the "front page" redirect
redir 302 {
if {path} is /
/ /Main/WebHome
}
# Shorter URLs
rewrite {
regexp ^(/[A-Z].*)
to /bin/view/{1}
}
# Communicate with Foswiki
fastcgi /bin /foswiki/socket {
split /bin
}
}
Foswiki
I find it simpler to launch Foswiki directly via systemd, rather than with the bundled init script. I do so with a simple
cd /foswiki/wiki/bin && ./foswiki.fcgi --listen=/foswiki/socket
.