Using Caddy as a Reverse Proxy for PicoLisp Web Applications
PicoLisp includes httpGate, a lightweight HTTP proxy tailored specifically for PicoLisp web services. However, once you need more mixed setup (static sites, other applications, multiple virtual hosts on the same port), you could prefer to replace httpGate with a general-purpose reverse proxy such as Nginx. But recently, I've found Caddy as a compelling alternative.(Note that PicoLisp version >= 25.11.30 is needed)
What is Caddy and Why Use It?
Caddy is a modern, open-source web server and reverse proxy written in Go. It supports several configuration formats, and one of them is the Caddyfile, that's designed to be readable and concise, which makes it particularly attractive for small setups. Reasons to consider Caddy instead of Nginx for PicoLisp:- Simple configuration – most use cases can be expressed in a few lines.
- Automatic HTTPS – TLS certificates are managed automatically via Let’s Encrypt (can be disabled if not needed).
- First-class reverse proxy support – clean syntax for proxying to PicoLisp backends.
- Easy virtual hosting – serving multiple domains and subdomains on the same port is trivial.
- Low operational overhead – minimal tuning required for small and medium sites.
Installing Caddy on Debian-Based Linux
There are several ways to install Caddy. For a small or self-managed server, downloading the official `.deb` package is straightforward.- Download the package from the Caddy GitHub releases page.
- Install it using dpkg: sudo dpkg -i caddy_*.deb`
- Enable and start the service: sudo systemctl enable caddy && sudo systemctl start caddy
Example Setup
The following example demonstrates:- A static site served on example.com
- A PicoLisp-based wiki served on wiki.example.com
- Reverse proxying requests to local PicoLisp HTTP backends
- Passing PicoLisp-specific headers expected by httpGate-style applications
Example Caddyfile (/etc/caddy/Caddyfile)
(proxy_options) {
header_up X-Pil "*Gate={http.request.scheme},*Adr={http.request.remote.host}"
header_up Host "{http.request.host}"
}
example.com {
root * /var/www/example.com/public
encode
file_server
handle_path /some-path/* {
reverse_proxy 127.0.0.1::8000
}
}
wiki.example.com {
@session path_regexp dyn ^/([0-9]{1,5})/(.*)$
handle @session {
reverse_proxy 127.0.0.1:{re.dyn.1} {
rewrite /{re.dyn.2}
import proxy_options
}
}
handle {
reverse_proxy / 127.0.0.1:65001 {
import proxy_options
}
}
}
Configuration Notes
- proxy_options
This reusable snippet injects headers expected by PicoLisp web applications, mimicking the information normally provided by httpGate. - Static site (example.com)
Files are served directly from the filesystem using file_server.
Requests under /some-path/ are forwarded to a local service on port 8000. - PicoLisp wiki (wiki.example.com)
Requests matching the /PORT/... pattern are dynamically routed to PicoLisp child processes listening on different ports.
All other requests are forwarded to the parent PicoLisp listener on port 65001.
https://picolisp.com/wiki/?caddy
| 16dec25 | abu |
