nginx1.7 添加lua
1:下载ngx_devel_kit.tar.gz 解压
2:下载nginx_lua_module.tar.gz 解压
3:# cd 到nginx的安装模块 后面跟的--add-module 即ngx_devel_kit和nginx_lua_module 解压路径
//注: 这里的openssh 和 pcre 也要下载解压(安装ngxin已经说了)
./configure --prefix=/usr/local/nginx --pid-path=/var/run/nginx.pid --with-openssl=/home/guotonglin/nginx/openssh-6.0p1 --with-pcre=/home/guotonglin/nginx/pcre-8.35 --with-http_stub_status_module --add-module=/home/guotonglin/nginx/lua-nginx-module-0.9.12rc2 --add-module=/home/guotonglin/nginx/ngx_devel_kit-0.2.19
4:执行make 和make install 命令
5:我这里是要实现监听反向代理服务器的返回内容:
具体的nginx.conf 配置:
//添加到http 和server之间
log_format main '$resp_body - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; // 这里是日志要显示的格式,我自己添加了 $resp_body(因为我要拿服务器返回的数据)
// server 和location 之间
lua_need_request_body on;
set $resp_body "";
body_filter_by_lua '
local resp_body = string.sub(ngx.arg[1], 1, 1000)
ngx.ctx.buffered = (ngx.ctx.buffered or "") .. resp_body
if ngx.arg[2] then
ngx.var.resp_body = ngx.ctx.buffered
end
';
启动nginx会报 如下错误 (复制来的)
./sbin/nginx: error while loading shared libraries:libluajit-5.1.so.2: cannot open shared object file: No such file or directory
此类问题通常使用ldconfig命令就能解决:
echo "/usr/local/lib" >/etc/ld.so.conf.d/usr_local_lib.conf
ldconfig
重启nginx
1:下载ngx_devel_kit.tar.gz 解压
2:下载nginx_lua_module.tar.gz 解压
3:# cd 到nginx的安装模块 后面跟的--add-module 即ngx_devel_kit和nginx_lua_module 解压路径
//注: 这里的openssh 和 pcre 也要下载解压(安装ngxin已经说了)
./configure --prefix=/usr/local/nginx --pid-path=/var/run/nginx.pid --with-openssl=/home/guotonglin/nginx/openssh-6.0p1 --with-pcre=/home/guotonglin/nginx/pcre-8.35 --with-http_stub_status_module --add-module=/home/guotonglin/nginx/lua-nginx-module-0.9.12rc2 --add-module=/home/guotonglin/nginx/ngx_devel_kit-0.2.19
4:执行make 和make install 命令
5:我这里是要实现监听反向代理服务器的返回内容:
具体的nginx.conf 配置:
//添加到http 和server之间
log_format main '$resp_body - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; // 这里是日志要显示的格式,我自己添加了 $resp_body(因为我要拿服务器返回的数据)
// server 和location 之间
lua_need_request_body on;
set $resp_body "";
body_filter_by_lua '
local resp_body = string.sub(ngx.arg[1], 1, 1000)
ngx.ctx.buffered = (ngx.ctx.buffered or "") .. resp_body
if ngx.arg[2] then
ngx.var.resp_body = ngx.ctx.buffered
end
';
启动nginx会报 如下错误 (复制来的)
./sbin/nginx: error while loading shared libraries:libluajit-5.1.so.2: cannot open shared object file: No such file or directory
此类问题通常使用ldconfig命令就能解决:
echo "/usr/local/lib" >/etc/ld.so.conf.d/usr_local_lib.conf
ldconfig
重启nginx