The main page and direct photo links open without a prompt. Each photo's pool is sealed with its own key, handed out by POST /k (served by the daemon in serve and export mode). The hold-and-solve card appears only for low-entropy clicks into a collection, too many low-entropy landings from one IP, or more than photo_limit photos per window, with escalating proof-of-work and a 429 cap. Build ids now sort chronologically within the same second. Co-Authored-By: Claude Opus 5.5 <[email protected]>
2.5 KiB
Cloudflare
Run the site behind a Cloudflare Tunnel (cloudflared.yml in this folder). In serve mode the tunnel points at LuPhoto on 127.0.0.1:8080. In export mode it points at Caddy or nginx, and LuPhoto itself listens on server.listen (127.0.0.1:8080 by default) for the key endpoint /k, so give the web server a different plain HTTP listener for the tunnel, for example http://photos.luciochen.com:8081 in the Caddyfile, or listen 127.0.0.1:8081; in nginx, and point the tunnel there.
Client addresses
LuPhoto limits photo keys per visitor address, so it must see the real one. Through the tunnel every request reaches the origin from cloudflared on loopback, and Cloudflare puts the visitor's address in CF-Connecting-IP. In /etc/luphoto/config.toml:
[server]
trusted_proxies = ["127.0.0.1/32", "::1/128"]
client_ip_header = "CF-Connecting-IP"
trusted_proxies must list the address the request comes from when it reaches LuPhoto: loopback for cloudflared, Caddy or nginx on the same machine (they pass CF-Connecting-IP through unchanged). If cloudflared runs on another host, add that host's address. Never trust a range the public can connect from directly, or anyone can choose their own address. Without the tunnel, behind Caddy or nginx only, keep the default "X-Forwarded-For".
Cache rules
Caching → Cache Rules, in this order:
- Key endpoint: when the URI path equals
/k, Bypass cache. It is a per-visitorPOSTanswered withCache-Control: no-store; it must never be cached or served from the edge. - Tiles, OG images and assets: when the URI path starts with
/t/,/og/or/assets/, set Eligible for cache, Edge TTL 1 month (or "use cache-control header"), Browser TTL "respect origin". Their names are content-hashed, so they never change. - Everything else (HTML,
/a/*including the per-photo pool files under/a/<slug>/p/,index.<build>.json,robots.txt): Edge TTL 1 minute or "respect origin" (max-age=60). Manifests and pool files are named after the build, so a new build needs no purge. Decoy tiles under/t/never change their bytes either, so rule 2 holds for them.
Keep "Cache by device type" and query-string variations off. Hotlink protection is done by LuPhoto, Caddy or nginx on /t/*, and /k checks Origin; Cloudflare's own Hotlink Protection can stay off, or be enabled for the same hostname. Bot Fight Mode and similar challenges must not be applied to /k, because they would answer the browser's fetch with an HTML page.