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: For PicoLisp users who want to host a static site, PicoLisp services, and possibly other services on the same server, Caddy offers an excellent balance between simplicity and capability.

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.
  1. Download the package from the Caddy GitHub releases page.
  2. Install it using dpkg: sudo dpkg -i caddy_*.deb`
  3. Enable and start the service: sudo systemctl enable caddy && sudo systemctl start caddy
Caddy runs as a system service and reads its configuration from `/etc/caddy/Caddyfile` by default.

Example Setup

The following example demonstrates:

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

This setup closely mirrors traditional PicoLisp deployments while allowing multiple services and domains to coexist cleanly behind a single reverse proxy.

https://picolisp.com/wiki/?caddy

16dec25    abu