Node.js

2 articles tagged “Node.js”.

9 min read

Rate limit by IP in Express and Nginx (without limiting your own proxy)

Per-IP rate limits fail in two opposite ways behind a proxy: every user shares the proxy's bucket, or every attacker gets a fresh one by forging X-Forwarded-For. Here is a setup for Express and Nginx that avoids both, tested against real requests.

  • Security
  • Nginx
  • Node.js

9 min read

Get the client IP address in Node.js and Express behind a proxy

Express gives you req.ip, but behind Nginx or a load balancer it's the proxy's address until you set trust proxy. Set it too loosely and any client can choose their own IP. Here is the setting for each common deployment, tested on Express 5.

  • Node.js
  • Security
  • Code

Try it

One GET request: location, network and bot signals

Free keys include 1.000 lookups a day. No card needed.