osec Bot Gate: Slow down AI scrapers and bad bots without Cloudflare
A small middleware for your own server: visitors solve one invisible proof-of-work check, then browse freely for a week. Search engines pass. No DNS move, no proxy in front of your site.
What it does
- Runs on your server (Node, Python, PHP)
- One invisible check per visitor per week
- Search engine crawlers allowed by default
- No traffic routed through us
What goes in, what comes out
- What goes in
- Page views reaching your own server, through a middleware file for Node, Python or PHP with your site key and secret.
- What comes out
- A visitor without the pass sees "Checking your browser" for about a second, then gets a signed cookie and browses for 7 days. Search engine crawlers pass without the check.
- Example
- app.use(osecGate({ sitekey: "osk_...", secret: OSEC_SECRET }))
- Limits
- Only HTML page views are gated; APIs, assets, form posts and feeds pass. Visitor passes are not counted against the request quota. It does not stop someone running real browsers. If osec.one cannot be reached, visitors get through for an hour.
How to set it up
Middleware on your own server. New visitors solve one invisible check, then browse for 7 days. Search engines pass. Nothing is proxied through us.
- Create a site key; keep the secret in an environment variable.
- Download the middleware for your stack (Node, Python or PHP) and add two lines.
- Deploy. Visitors without the gate cookie see "Checking your browser…" for about a second.
- Visitor passes are not counted against your daily quota.
node (express)
// https://osec.one/assets/osec-gate/osec-gate.js
const osecGate = require("./osec-gate");
app.use(osecGate({ sitekey: "osk_...", secret: process.env.OSEC_SECRET }));python (fastapi / flask)
# https://osec.one/assets/osec-gate/osec_gate.py
from osec_gate import OsecGateASGI, OsecGateWSGI
app.add_middleware(OsecGateASGI, sitekey="osk_...", secret=os.environ["OSEC_SECRET"])
# Flask: app.wsgi_app = OsecGateWSGI(app.wsgi_app, sitekey="osk_...", secret=os.environ["OSEC_SECRET"])php / wordpress (top of wp-config.php)
// https://osec.one/assets/osec-gate/osec-gate.php
require __DIR__ . '/osec-gate.php';
osec_gate(['sitekey' => 'osk_...', 'secret' => getenv('OSEC_SECRET')]);Good to know
- Only HTML page views (GET/HEAD with Accept: text/html) are gated. APIs, assets, POSTs and feeds pass: protect forms with osec Captcha.
- Crawlers (Google, Bing, DuckDuckGo, Apple, Yandex, Baidu, social previews) pass by user agent. Set verifyCrawlers / verify_crawlers to confirm them by reverse DNS.
- The cookie is signed with your secret and tied to the browser's user agent.
- If osec.one can't be reached, visitors get through for an hour (failOpen / fail_open, on by default).
- It raises the cost of scraping; it doesn't stop a determined attacker running real browsers.