Closed luisalrp closed 5 months ago
Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.
Have you confirmed it is not present?
$ docker exec -it swag nginx -V 2>&1 | tr ' ' '\n' | grep njs
--add-dynamic-module=/home/buildozer/aports/main/nginx/src/njs-0.7.11/nginx
Hello Roxedus
Thanks for answering. When I run the docker exec instruction I got the same line, but not sure what can I do from it. I mean, if I try to go there, there is no folder or file and checking the njs conf examples neither the /etc/nginx/njs is present.
Here is an example of a conf file :
load_module modules/ngx_http_js_module.so;
events { }
http {
js_path "/etc/nginx/njs/";
js_import utils.js;
js_import main from http/hello.js;
server {
listen 80;
location = /version {
js_content utils.version;
}
location / {
js_content main.hello;
}
}
}
You need the nginx-mod-http-js
OS package, you can install it with the universal package mod.
You then have the needed directives present, like js_path
.
Then you just have to configure nginx like normal, with the additional directives.
My quick test was something like adding
js_path "/config/nginx/njs/";
js_import main from hello.js;
to the existing http block, where I created the njs directory, and put the hello.js file from the example repo you linked. Then add the location, like you would with a proxy_pass, ie
location = /hello.html {
js_content main.hello;
}
to a server block.
Thank you so much Roxedus!
Is this a new feature request?
Wanted change
I would like Nginx njs scripting language installed to perform additional actions not available on SWAG.
Reason for change
nsj would enable new capabilities, like checking apikey validity on nginx before a request reaches an upstream server, manipulating response headers or writing flexible asynchronous content handlers and filters
Proposed code change
I don't know the best approach. Maybe a dockermod would be better option because some users would not like to have njs by default for security concerns.
Here is the documentation.