NGINX Integration
Block or rate-limit requests from ipinsights.io blocklisted IPs in NGINX —
no modules required, just core geo and map directives.
Overview
NGINX's geo directive can load a plain IP-list file from disk and expose the
result as a variable. We'll generate that file from the
ipinsights.io blocklist every hour and use the variable in any
server block to return 403, throttle the request, or simply tag it
for downstream logging.
Prerequisites
- NGINX 1.18+ (any flavour — open-source, Plus, OpenResty, Angie)
curlavailable on the host and outbound HTTPS tohttps://ipinsights.io- Permission to write into
/etc/nginx/blocklists/and to reload NGINX
Step 1 — Pull the Blocklist
Write the list out as an NGINX geo-compatible file — one
ip 1; entry per line.
Save as /usr/local/bin/ipinsights-nginx-sync.sh:
Make it executable and schedule hourly:
Step 2 — Add the geo Block
In nginx.conf inside the http { } context:
Prefer rate-limiting? Replace the if with
limit_req zone=ipinsights_slow burst=5 nodelay; inside any
location after gating on $ipinsights_block.
Step 3 — Optional: Tag the Access Log
Surface the verdict in your access log so dashboards and SIEMs can show it without re-querying:
Step 4 — Verify
Notes
- Trust the real client IP: if NGINX sits behind a CDN, set
real_ip_header/set_real_ip_fromso$remote_addrreflects the actual visitor before thegeoblock evaluates. - CIDR support:
geoaccepts CIDR notation, so pointing the sync script at/downloads/blocklist-cidr.txtis also valid and reduces the line count significantly.
API Key: Not required for the public blocklist used by this integration.
Request Higher API Limit
Running a high-volume NGINX deployment? If the default rate limit isn't enough for your environment, submit a request below and we'll review it.