Is it possible to persist some data in the javascript module of nginx?
I need to safe some data from the request to validate if the following requests are allowed.
Is it possible to persist some data in the javascript module of nginx?
I need to safe some data from the request to validate if the following requests are allowed.
2
Answers
I would try to use it by writing a file and reading it.
https://github.com/nginx/njs/issues/75 Here is someone kinda using it.
Second idea would be to just try to setup it as a nginx variable or something.
https://www.docs4dev.com/docs/en/nginx/current/reference/http-ngx_http_js_module.html
I would recommend to use ngx_http_keyval_module. it allows to keep key-value dictionaries in the shared memory available to all requests and workers.
Take a look at the number of requests per client IP example.
nginx.conf
num_requests_module.js:
Checking: