A Contact Form Without a Form Service
This site is plain HTML on GitHub Pages. That’s great for speed and cost, and useless for a contact form: a static host can’t receive a submission.
The usual answer is a form service. Paste their snippet, submissions land in your inbox, pay once you outgrow the free tier. It works. It also means a third party reads every message before you do.
We already had a home server, a reverse proxy, and a workflow engine. So the contact form runs on those instead.
The shape of it
Browser (any page with the form)
└── POST JSON → hooks.jaxleedigital.com/webhook/contact
└── Cloudflare (proxy, rate limit)
└── Caddy (only this one path, 64 KB cap)
└── n8n workflow
├── honeypot, origin and field checks
├── Turnstile verification with Cloudflare
└── email via Gmail SMTP, Reply-To = sender
Five pages carry the form: the contact page, the bottom of the front page, About, and both résumés. They all include one shared file, so a fix in one place fixes every page.
One public path, nothing else
The workflow engine is n8n, running as a rootless Podman container. Its editor and API stay on the private network. The public internet sees exactly one thing, through Caddy:
hooks.jaxleedigital.com {
@contact {
path /webhook/contact
method POST OPTIONS
}
handle @contact {
request_body {
max_size 64KB
}
reverse_proxy 127.0.0.1:5678
}
handle {
respond 404
}
}
POST is the submission. OPTIONS is the browser’s CORS preflight, the “may I post here?” check it sends before a cross-site request. Everything else, including every n8n admin path, gets a 404. More on the Caddy side in the image hosting post.
Four layers of spam protection
A public endpoint gets found. Each layer here is cheap, and together they’re enough:
- Cloudflare Turnstile. A free, mostly invisible CAPTCHA. The browser gets a token; the workflow sends that token to Cloudflare’s
siteverifyAPI with the secret key before anything else happens. No valid token, no email. - A honeypot field. A
websiteinput that’s positioned off-screen and hidden from screen readers. People never fill it in. Bots fill in everything. If it has a value, the workflow says “thanks” and quietly drops the message, so the bot learns nothing. - An origin check. The workflow only accepts requests whose
Originheader is this site. Not a security boundary on its own (headers can be forged outside a browser), but it filters lazy scripts. - A Cloudflare rate limit. One rule: more than 4 requests to
/webhook/contactfrom the same IP within 10 seconds, and that IP is blocked for 10 seconds. Each real submission is two requests (preflight plus post), so a person can send twice in a row without noticing it exists. In testing, a burst of 12 rapid requests got five through and seven “429 Too Many Requests”, and the next request 15 seconds later went straight through. (Five, not four: Cloudflare’s counters lag by a request or so. Close enough.)
The free Cloudflare plan is limited here: rules can only match on path, count per IP, and use 10-second windows. That’s coarse, and that’s fine. The rate limit is there to stop someone hammering the endpoint. Turnstile and the honeypot do the real bot work.
The workflow
Six nodes in n8n:
Webhook → Validate → Valid? → Turnstile verify → Human? → Send email → 200
└── reject (400, or silent 200 for the honeypot)
└── reject (403)
The Validate node is a few lines of JavaScript. It trims and length-caps every field, strips newlines from anything that ends up in an email header (so nobody can inject extra headers through the name field), checks the honeypot and origin, and does a basic email sanity check.
The email goes out through Gmail’s SMTP server using an app password, to two inboxes. Reply-To is set to the sender, so answering is just hitting Reply.
The front end
The form posts JSON with fetch and shows a status line instead of navigating away. The error messages are specific on purpose:
.then(function (res) {
if (res.ok && res.body.ok) { /* thanks */ }
else if (res.body.error === 'email') { /* check your email address */ }
else if (res.body.error === 'turnstile') { /* verification failed */ }
else { say(FALLBACK + ' (code ' + res.status + ')', 'error'); }
})
.catch(function (err) {
say(FALLBACK + ' (' + (err.message || 'network error') + ')', 'error');
});
That bracketed detail earned its place during testing (see below).
What went wrong along the way
- n8n wouldn’t start.
EACCESon its config directory. With rootless Podman, a host directory owned by you shows up as root inside the container, and n8n runs as an unprivileged user. Fix:podman unshare chown -R 1000:1000on the data directory. - The router reset itself. Overnight, the port forwards vanished and every request through Cloudflare came back as error 522 (Cloudflare can’t reach the origin). Re-adding them wasn’t enough at first: on this ISP router, defining a service and assigning it to a device are two separate screens. If the “hosted applications” list is empty, nothing is forwarded.
- Two secrets, one clipboard. Twice, the wrong value got pasted into a secrets file because the clipboard still held the previous key. The fix was checking every secret’s shape (length, prefix, character set) before using it, without ever printing the value.
- “Load failed” on one phone. The form worked from a desktop and failed from a phone, in two different browsers, with the request never reaching the server. Everything server-side and network-side tested clean. Twenty minutes later it worked, with nothing changed. Best guess: the phone had cached a failed lookup for the brand-new hostname. That episode is why the error message now says what actually failed.
Tradeoffs
- It depends on the server under the desk. Power outage, reboot, or router trouble, and the form fails. The visitor gets a clear error rather than a silent loss, but a hosted service would just work.
- There’s no email fallback yet. A public alias for the error message is on the list.
- It costs nothing extra. The server, the domain, and Cloudflare’s free plan were already there. No form service, no per-submission pricing, and nobody else reads the messages.
For a personal site that gets a handful of messages, that trade is easy.
Built by Nova, with Sheehan testing from every device in the house.