One binary · written in C · Caddy-style config

The reverse proxy that
routes on what’s inside
the request.

limer.sh is an ultra-fast HTTP server and load balancer that distributes traffic by JSON fields, form fields, body regexes, headers, cookies, the path, or the client address — not just the URL. One binary, a readable Limerfile, automatic HTTPS, HTTP/3, HTTP/2 and gRPC.

Get started → ★ Star on GitHub $ git clone && make
Limerfile
example.com {
    # Same customer → same upstream, chosen by a field in the JSON body
    route orders {
        match method POST
        match json type == order refund
        reverse_proxy 10.0.1.10:8080 10.0.1.11:8080 {
            lb_policy hash json customer.id
        }
    }

    # Everything else: least-connections with active health checks
    reverse_proxy 10.0.0.10:8080 10.0.0.11:8080 10.0.0.12:8080 {
        lb_policy least_conn
        health_uri /healthz
    }
}
Payload-based distribution

Balance on the request, not just the URL.

Most proxies can only see the method and path. limer.sh looks inside the request and picks a handler or an upstream from its contents. lb_policy hash json customer.id sends every request for a customer to the same backend with weighted rendezvous hashing — so when an upstream leaves, only its keys get remapped.

Match with == != ~ !~ > < ^= *= exists missing, AND matchers together, OR their values, and negate any of them.

  • json
  • form
  • body regex
  • header
  • cookie
  • query
  • path
  • host
  • method
  • remote_ip
  • tls_client
  • split %
shard by tenant
:8080 {
    route events {
        match path /events/*
        match json event == signup purchase
        to :9001 :9002 :9003
        lb_policy hash json tenant
    }

    # 5% canary — sticky per user
    route {
        match split 5 cookie session
        reverse_proxy canary.internal:8080
    }

    reverse_proxy :9001 :9002 :9003
}
Everything in one binary

A full edge, nothing to assemble.

limer.sh works like Caddy: automatic certificates, zero-downtime reloads, an admin API — plus the payload routing and balancing that Caddy lacks.

Payload routing & hashing

Route and balance on JSON, form, body, header, cookie, query, path or client IP. Rendezvous hashing keeps keys stable across upstream changes.

Automatic HTTPS

Let’s Encrypt over http-01, tls-alpn-01 or dns-01 with wildcards. Renews itself. tls internal for local dev.

HTTP/3, HTTP/2 & gRPC

HTTP/3 over QUIC with one line: http3. HTTP/2 both sides via h2c:///h2://, trailers intact. Unary and bidirectional streaming gRPC pass straight through.

Smart load balancing

Round robin, least-conn, random, IP/URI hash, sticky cookies — with weights, active health checks and passive ejection. A 404 or 503 can ask the next backend, then fall back to a redirect.

Caching & rate limits

In-memory LRU cache honouring Cache-Control, Vary, ETag and stale-while-revalidate: one stored body, compressed per client, purged by path or prefix over the admin API. Token-bucket rate limits keyed by any placeholder.

Static files & compression

file_server with ranges, try_files and directory browsing. gzip, zstd and brotli, streamed and negotiated.

Safe deploys

Reloads and limer upgrade with no downtime and the same pid, every server in rotation staying in rotation. New configs and binaries run as a 5% canary and roll back on their own if they cause 5xx — the bad file is moved aside so a restart can’t bring it back.

Dynamic upstreams

Pools from DNS A/AAAA or SRV records, or backends that self-register over the admin API — health- and settle-gated, no external registry, and back in rotation at once after a restart or an upgrade. Members can broadcast to each other (cache busts, live updates) with no message broker. Mutual TLS, mirroring and canary splitting built in.

Ops you can see

Prometheus metrics, JSON upstream status, access logs that roll (by size, count and age, gzipped), runtime drain and weight overrides that survive reloads, multi-process workers with SO_REUSEPORT.

DoS mitigation

Cap concurrent connections and the new-connection rate per source IP at accept time, and auto-ban repeat offenders. trusted_proxies keys it on the real client behind a CDN.

Low profile

limer doesn’t announce itself: no Server header by default, neutral cookie names, proxied responses untouched. Set server_header nginx to masquerade.

Autoscaling hooks

scale_up runs your command when traffic spikes; a backend shutting down calls POST /drain and stops getting new requests — both behind a secret, with bans for floods. Crashed workers restart on their own.

Use cases

Where payload-aware routing pays off.

The same binary is a plain reverse proxy and a content-aware one. A few shapes it fits particularly well:

Payment routing

Route each payment by method, currency and country

Cards in EUR or GBP go to the EU processor, GCash and PayPal to the wallet service, peso transfers to the APAC ledger — and each country stays on one node, so its tax rules, FX rates and fraud models stay warm.

match json payment.method == card match json currency == EUR GBP to eu-1:8080 eu-2:8080 eu-3:8080 lb_policy hash json customer.country
Content routing

Route by what’s in the request

Send refunds to the finance pool, premium tenants to bigger boxes, v2 payloads to the new service — decided by a field in the body, not the URL.

match json type == refund to finance-1:8080 finance-2:8080
API edge

One binary in front of your API

Automatic HTTPS, per-key rate limits and per-IP DoS mitigation at the edge — no sidecars, no cert cron, no extra WAF to run for L7 abuse.

rate_limit { key {header.X-Api-Key} rate 100r/s } ip_guard { max_conns_per_ip 200 }
gRPC

Balance gRPC, trailers intact

Multiplex gRPC over HTTP/2 to a pool, with real trailers (grpc-status) preserved — unary and bidirectional streaming both pass through.

reverse_proxy h2c://10.0.0.5:50051 \ h2c://10.0.0.6:50051
Progressive delivery

Canary a sticky slice of users

Peel a deterministic percentage of traffic to a canary — the same users every time — and mirror a copy of prod to staging to test on real load.

match split 5 cookie session reverse_proxy canary.internal:8080
Drop-in edge

Replace nginx or Caddy

Static files, compression, redirects, virtual hosts and TLS in a familiar Caddy-style config — at roughly 3–5× the throughput.

root /srv/www file_server encode gzip zstd br

Full, runnable examples in USECASE.md.

Security

Strict at the edge. Nothing loaded at runtime.

limer.sh sits in front of your application, so it treats every client and every upstream as hostile — and keeps the code that does it small enough to read.

No request smuggling

Conflicting Content-Length and Transfer-Encoding, odd codings, obsolete line folding or a space before a colon get a 400 and a closed connection. Bodies are always re-framed upstream.

Everything is bounded

64 KiB heads, 128 headers, max_body, slow-client and idle timeouts, per-worker connection caps, HTTP/2 stream limits, bounded JSON nesting. Nothing grows without a limit.

Hostile upstreams

Bogus status lines, conflicting framing, NUL bytes or an unsolicited 101 from a backend become a clean 502 — never a poisoned keep-alive connection.

A locked admin API

A bearer secret on every endpoint but /health, compared in constant time. Webhooks like POST /drain and /scale_up are rate limited, and callers that guess secrets or flood them get banned.

Files stay in their root

Paths are percent-decoded and normalised before use, .. can never leave root, and dotfiles are hidden. Header values can never carry CR or LF.

Tested like an attacker

A 99-check black-box suite attacks a live instance — smuggling, malformed input, a scripted hostile upstream, wire-level fuzzing. Parsers are fuzzed on every CI build; clean under ASan, UBSan and Valgrind.

By design

Why there are no third-party plugins

Plugin ecosystems make a server easy to extend — and make its security the sum of everyone’s code. limer.sh deliberately has none.

  • A plugin runs inside the proxy. C has no sandbox for in-process code: one module’s buffer overflow is the server’s overflow, with every request, cookie and TLS private key in the same memory.
  • Every plugin is a supply chain. Another author, another release stream, another chance of a compromised update — in the one component that sees all of your traffic.
  • Nothing loads at runtime. No module loader, no dlopen, no embedded scripting: a config file cannot pull in code. What you audit is what runs — one binary, about 18,600 lines of C, from one repository.
  • Everything is tested together. The fuzzers and the security suite cover every feature in the build. A plugin matrix is a set of combinations nobody tests.

The trade-off is real: you can’t bolt a feature on. Ask for it in an issue — or keep it out of process, where a bug stays in its own address space.

extend it out of process
{
    # hooks run as their own processes
    acme_dns_script /etc/limer/dns-hook.sh
    scale_up {
        requests 1000r/s
        exec "/etc/limer/scale-up.sh"
    }
    # webhooks need the secret
    admin 10.0.0.1:2019 {
        secret {$LIMER_ADMIN_SECRET}
    }
}

example.com {
    # your own service is the plugin
    route auth {
        match path /login/*
        reverse_proxy 127.0.0.1:7000
    }
    reverse_proxy 10.0.0.5:8080
}
Performance

An epoll data path in C — about 3–5× Caddy.

Same 4-vCPU VM, same two backends, same round_robin policy and an enlarged keep-alive pool, driven by wrk. HTTP/1.1 reverse-proxy throughput:

ScenarioCaddy v2.10limer.shRatio
1 core · GET round robin · 100 conns9,200 req/s32,000 req/s3.5×
1 core · POST 120 B JSON8,600 req/s31,000 req/s3.6×
1 core · GET · 1000 conns7,400 req/s26,000 req/s3.5×
4 cores · GET round robin · 100 conns23,500 req/s103,000 req/s4.4×
4 cores · POST 120 B JSON20,500 req/s90,000 req/s4.4×
4 cores · GET · 1000 conns22,500 req/s115,000 req/s5.1×

Head to head with nginx and HAProxy

One worker each on a 1-vCPU VM, keep-alive to the same two backends, wrk for 10 s, best of 3. The three are level: no gap is larger than about 6%.

Scenariolimer.shnginx 1.24HAProxy 2.8
GET · keep-alive · 100 conns25,402 req/sp99 6.0 ms25,456 req/sp99 5.3 ms25,131 req/sp99 5.8 ms
GET · keep-alive · 1000 conns18,553 req/sp99 97 ms17,531 req/sp99 86 ms17,942 req/sp99 67 ms
POST 120 B JSON · 100 conns24,449 req/sp99 6.2 ms24,240 req/sp99 6.3 ms24,901 req/sp99 5.7 ms
New connection per request10,256 req/sp99 12.4 ms10,064 req/sp99 13.2 ms10,550 req/sp99 11.8 ms

HTTP/3 vs HTTP/2 vs HTTP/1.1

One limer.sh worker over TLS, driven by h2load on the same 1-vCPU VM, 100,000 requests per run, best of 3, zero failures. With several requests in flight per connection — how browsers load pages — HTTP/3 is the fastest.

Connections × in flightHTTP/1.1 + TLSHTTP/2HTTP/3
10 × 10 (multiplexed)—17,470 req/sp99 8.9 ms25,209 req/sp99 6.8 ms
10 × 120,500 req/sp99 0.8 ms14,399 req/sp99 1.0 ms10,753 req/sp99 1.6 ms
100 × 120,101 req/sp99 7.6 ms13,986 req/sp99 9.7 ms8,797 req/sp99 16 ms

~5 KB per active connection · one worker can hold ~500,000 connections in ~2.5 GB · reproduce it all with bench/run.sh, bench/compare.sh and bench/protocols.sh

What’s new

Found in production, fixed, then tested.

Each of these turned up running limer in front of real sites, and each came with a test that failed before its fix.

  • No 503s through a reload, a restart or an upgrade

    A reload keeps every server’s health, even when a route added before a pool renames it, and the servers restored from the saved registry go straight back into rotation after a restart or limer upgrade. Only a server that registers anew still waits for its health check and settle.52b0fa0

  • Early answers reach the client

    An upstream that answers while the upload is still coming (a 413 at its own limit), or limer’s own 413 past max_body, now closes as nginx’s lingering close does: the client reads the answer, not a reset.8854694

  • Access logs that roll

    output file <path> { roll_size … roll_keep … roll_keep_for … }, on by default with Caddy’s defaults (100 MiB, 10 files, 90 days, gzipped), and no line lost or written twice across rolls while every worker writes.d7b5fc4 · d97f0dc · f399ade

  • HTTP/2 pass-through answers logged again

    A chunked answer streamed over HTTP/2 as it came is logged and counted once more, and its upstream connection goes back to the pool.acf38aa

  • A response cache to trust in front of a compressing app

    Six correctness fixes (no compressed body served as plain, every Cache-Control and Vary line read, a cache key per port, a request with a cookie or credentials never answered from another visitor’s entry, no-cache revalidated), one stored body compressed per client, and POST /cache/purge by path or prefix on every worker.8bab3f4 · e6be0be

  • Reloads that answer

    limer reload waits for the master’s answer and exits 1 with the reason; checks run as root leave no log file behind; a reload no longer waits for a certificate order; a key and its certificate are written together.e80ae13 · 4f80ddb

Quickstart

Running in under a minute.

No runtime, no modules to install — just libc and whatever optional libraries you have. Linux (epoll) or macOS (kqueue).

  1. Build it

    Clone and make. Optional libs (OpenSSL, nghttp2, zstd, brotli) are auto-detected; make install drops it in /usr/local/bin.

  2. Write a Limerfile

    One directive per line, blocks in braces — the Caddyfile syntax you already know, with import, snippets and {$ENV}.

  3. Run & reload

    limer run in the foreground (perfect under systemd). limer reload swaps config with zero downtime; limer validate checks it first.

try it locally
# build
git clone https://github.com/limer-sh/limer
cd limer && make

# spin up three test backends
python3 tests/backend.py 9001 shard-a &
python3 tests/backend.py 9002 shard-b &
python3 tests/backend.py 9003 shard-c &

# route by payload
./limer run -c examples/payload-routing.Limerfile

curl -X POST localhost:8080/echo \
     -d '{"tenant":"acme","event":"signup"}'