Caddy is a powerful, enterprise-ready, open source web server with automatic HTTPS written in Go.
To install caddy, first add the caddy
program to your gokrazy instance:
gok add github.com/caddyserver/caddy/v2/cmd/caddy
Then, open your instance’s config.json
in your editor:
gok edit
And make the following changes:
run
) and to make caddy locate its config file (--config
).{
"Hostname": "webserver",
"Update": {
"HTTPPort": "1080"
},
"Packages": [
"github.com/gokrazy/fbstatus",
"github.com/gokrazy/hello",
"github.com/gokrazy/serial-busybox",
"github.com/gokrazy/breakglass",
"github.com/caddyserver/caddy/v2/cmd/caddy"
],
"PackageConfig": {
"github.com/caddyserver/caddy/v2/cmd/caddy": {
"CommandLineFlags": [
"run",
"--config",
"/etc/caddy/Caddyfile"
],
"ExtraFilePaths": {
"/etc/caddy/Caddyfile": "Caddyfile"
}
}
}
}
Then, create the referenced Caddyfile
extra file and modify it to your
liking. In this example, we explicitly configure an HTTP listener to disable
Caddy’s automatic HTTPS setup, so that your server will work without a
publically reachable address.
cat > ~/gokrazy/webserver/Caddyfile <<'EOT'
http://:80 {
root * /tmp
file_server browse
}
EOT
Then, deploy as usual:
gok update
Tip: When using breakglass
, use the -gokrazy_url=:1080
flag to overwrite
the port.