Datasette 用户终于有了一个现成的 IP 限流方案,能有效抵御恶意爬虫,保护站点资源。如果你正在用 Datasette 部署公开数据服务,这个插件可以直接拿来用,配置也很灵活。
Simon Willison 发布了 datasette-ip-rate-limit 0.1a0,一个用于 Datasette 的 IP 限流插件。该插件由 Codex(GPT-5.5 xhigh)编写,旨在阻止行为不当的爬虫对特定区域进行快速请求。生产配置支持基于请求头的 IP 识别、最大键数、豁免路径以及灵活的限流规则,例如对特定路径在 60 秒窗口内限制 60 次请求,超限后封禁 20 秒。
datasette-ip-rate-limit 0.1a0
Release: datasette-ip-rate-limit 0.1a0 The datasette.io site was being hammered by poorly-behaved crawlers, so I had Codex (GPT-5.5 xhigh) build a configurable rate limiting plugin to block IPs that were hammering specific areas of the site too quickly. Here's the production configuration I'm using on that site for the new plugin: datasette-ip-rate-limit : header : Fly-Client-IP max_keys : 10000 exempt_paths : - " /static/* " - " /-/turnstile* " rules : - name : public-demo-multi-parameter-table-pages paths : - " /global-power-plants/* " - " /legislators/* " window_seconds : 60 max_requests : 60 block_seconds : 20 Tags: datasette , rate-limiting , codex