关于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 };

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理