Periodically refreshing an allowlist in njs
Sergey A. Osokin
osa at freebsd.org.ru
Sat Mar 26 21:45:55 UTC 2022
Hi Tom,
hope you're doing well.
On Sat, Mar 26, 2022 at 09:55:48PM +0100, Tom Hall wrote:
>
> I am looking to replace some lua scripting we have to do an allowlist,
> I found https://medium.com/geekculture/building-a-simple-bot-protection-with-nginx-javascript-module-njs-and-typescript-386b2207ba90
> and it seems to give me a good idea how to port my lua
>
> const fs = require('fs');
> const badReputationIPs = loadFile('/var/lib/njs/ips.txt');
>
> Is there an equivalent in njs? It seems not if you are starting a new
> lightweight VM for every request.
> Is the answer to do a subrequest and cache it or something?
I'd recommend to tweak the architecutre a bit and use a key-value
store instead of an access to a file.
--
Sergey A. Osokin
More information about the nginx-devel
mailing list