~ Notes for njs and Nginx modules development in Js
Nginx modules can be written in multiple languages like C, Perl, Lua or Js with Njs. Because of a compiler written by the team of Nginx you shouldn't use it for big calculus or cryptography.
You can install njs with the next commands for ubuntu:
# To run in admin mode or with sudo
apt update
apt install -y curl gnupg2 ca-certificates lsb-release debian-archive-keyring
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor | tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" | tee /etc/apt/sources.list.d/nginx.list
apt update
apt install -y nginx-module-njs
Finally you have to add the next line to /etc/nginx/nginx.conf
and start nginx:
load_module modules/ngx_http_js_module.so;
# To run in admin mode or with sudo
service nginx start
🐳 ~ For testing, you can use a Docker image that I have created for this.