乐趣区

关于nginx:njs

nginx 装置 njs 模块

yum install nginx-module-njs

援用 njs 模块

// nginx.conf
 load_module modules/ngx_http_js_module.so;

 events {}
 http {server {}
}

运行

// nginx.conf

 load_module modules/ngx_http_js_module.so;

 events {}

 http {
   js_path "/etc/nginx/njs/";

   js_import index.js;

   server {
     listen 80;

     location / {js_content index.hello;}
  }
}
// /etc/nginx/njs

function hello(r) {r.return(200, "Hello world,  index!");
}

export default {hello};
退出移动版