关于nginx:njs

8次阅读

共计 371 个字符,预计需要花费 1 分钟才能阅读完成。

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

正文完
 0