node-red-contrib-ipgeolocation 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -2
- package/nodes/ipgeo-bulk.html +1 -0
- package/nodes/ipgeo-lookup.html +1 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -340,7 +340,33 @@ return msg;
|
|
|
340
340
|
|
|
341
341
|
### Geolocate the visitor in an HTTP flow
|
|
342
342
|
|
|
343
|
-
|
|
343
|
+
Give `ipgeo-lookup` one validated client IP. Do not map the raw `req.headers['x-forwarded-for']` chain: the node sends it as one value, for example `203.0.113.7, 10.0.0.2`, and any entry your own proxies did not add is whatever the client sent. Never let the input be empty either, because the API then looks up the caller's IP, which is your Node-RED server.
|
|
344
|
+
|
|
345
|
+
Read the address from `msg.req.ip`. The **http in** node runs on Express, which sets `msg.req.ip` to a single address:
|
|
346
|
+
|
|
347
|
+
- **Direct connection:** with the default settings, `msg.req.ip` is the socket's remote address.
|
|
348
|
+
- **Behind a reverse proxy:** list your proxies under `httpServerOptions` in Node-RED's `settings.js`. Express then reads `X-Forwarded-For` from right to left, skips the trusted proxies, and uses the first address it does not trust. Do not set `"trust proxy": true`, which trusts every entry, including ones the client wrote.
|
|
349
|
+
|
|
350
|
+
```javascript
|
|
351
|
+
// settings.js: nginx on the same host as Node-RED, behind a load balancer at 10.0.0.2
|
|
352
|
+
httpServerOptions: {
|
|
353
|
+
"trust proxy": ["loopback", "10.0.0.2"],
|
|
354
|
+
},
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
Add a Function node with two outputs between **http in** and `ipgeo-lookup`. Wire output 1 to `ipgeo-lookup` and output 2 to a fallback such as an **http response**, then set **IP / Domain** to the `msg` property `ipgeo_ip`:
|
|
358
|
+
|
|
359
|
+
```javascript
|
|
360
|
+
let ip = msg.req.ip || "";
|
|
361
|
+
if (ip.startsWith("::ffff:")) ip = ip.slice(7); // IPv4 client on a dual-stack listener
|
|
362
|
+
if (!/^(\d{1,3}\.){3}\d{1,3}$|^[0-9a-f]*:[0-9a-f:.]+$/i.test(ip)) {
|
|
363
|
+
return [null, msg]; // not one IP address; an empty value would look up your server's IP
|
|
364
|
+
}
|
|
365
|
+
msg.ipgeo_ip = ip;
|
|
366
|
+
return [msg, null];
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
If your proxy instead overwrites a dedicated header with the client address, for example nginx `proxy_set_header X-Real-IP $remote_addr;`, read `msg.req.headers['x-real-ip']` in the first line. Do this only when clients cannot reach Node-RED without passing through that proxy.
|
|
344
370
|
|
|
345
371
|
### Block proxies and VPNs at the edge
|
|
346
372
|
|
|
@@ -408,7 +434,7 @@ Use the <code>ipgeo-security</code> node, or enable the <code>security</code> in
|
|
|
408
434
|
|
|
409
435
|
<details>
|
|
410
436
|
<summary><strong>Does it work behind a reverse proxy?</strong></summary>
|
|
411
|
-
Yes.
|
|
437
|
+
Yes. List your proxies under <code>"trust proxy"</code> in <code>httpServerOptions</code> in Node-RED's <code>settings.js</code>. Express then sets <code>msg.req.ip</code> to one client address selected through those trusted proxies; check it in a Function node and pass it to <code>ipgeo-lookup</code> as a dynamic <code>msg</code> input. Do not pass the raw <code>X-Forwarded-For</code> header, which can hold several addresses, some of them written by the client. The "Geolocate the visitor in an HTTP flow" recipe shows the full setup.
|
|
412
438
|
</details>
|
|
413
439
|
|
|
414
440
|
<details>
|
package/nodes/ipgeo-bulk.html
CHANGED
package/nodes/ipgeo-lookup.html
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-ipgeolocation",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Node-RED nodes for the IPGeolocation.io v3 API: IP geolocation, security and threat intelligence (VPN, proxy, and TOR detection), abuse contacts, ASN lookup, bulk IP processing, timezone, astronomy, and user-agent parsing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node-red",
|
|
@@ -79,6 +79,8 @@
|
|
|
79
79
|
"multer": "^2.5.0",
|
|
80
80
|
"express": "^4.22.3",
|
|
81
81
|
"qs": "^6.17.0",
|
|
82
|
-
"body-parser@^1": "^1.20.9"
|
|
82
|
+
"body-parser@^1": "^1.20.9",
|
|
83
|
+
"glob": "^14.0.2",
|
|
84
|
+
"minimatch": "^11.0.1"
|
|
83
85
|
}
|
|
84
86
|
}
|