How-to
Website
Web app
Serve a site with Caddy
This recipe serves a WebFluent build with Caddy, which also gets and renews the site's TLS certificate. You need a server running Caddy, and a build/ folder from wf build (Install wf on a build machine). Add a site block to the Caddyfile:
example.com {
root * /var/www/site
encode gzip
file_server {
precompressed gzip
}
try_files {path} {path}/ {path}.html /index.html
header X-Content-Type-Options nosniff
}
How it works
Then upload build/ to /var/www/site and reload Caddy.
rootis the folder the build is uploaded to.precompressed gzipserves the.gzfiles the build wrote;encode gzipcompresses on the way out what has none.try_filesdecides what a path reaches: the file, the folder'sindex.html, the.htmlfileclean_urls: "file"writes, and last/index.html, the single-page fallback.headersends a security header; add the others frombuild/_headersthe same way (Set cache and security headers).
Check it
Open a deep link directly and reload it, then check the headers with curl -I. Then go through Check a deploy.
Variations
For a static build, remove /index.html from the end of try_files, so an unknown path is a 404.