nginx配合lua打印响应报⽂和请求报⽂⽇志下载安装LuaJIT - LuaJIT-2.0.5
# wget /download/LuaJIT-2.0.
# tar -zxvf LuaJIT-2.0.
# cd LuaJIT-2.0.5
# make && make install
下载nginx lua模块 - lua-nginx-module-0.10.10
# wget github/openresty/lua-nginx-module/archive/v0.10.
# tar -zxvf v0.10.
# export LUAJIT_LIB=/usr/local/lib
# export LUAJIT_INC=/usr/local/include/luajit-2.0
安装 nginx 依赖
# yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
下载 nginx
这⾥我下载的 1.16.1 版本
安装 nginx
./configure --prefix=/home/yunpay/nginx --with-stream --with-http_ssl_module --add-module=../lua-nginx-module-0.10.10/ make && make install
出现
./nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory
解决⽅法:
# ln -s /usr/local/lib/libluajit-5.1.so.2/lib64/libluajit-5.1.so.2
浏览器验证
打不开⽹页
解决⽅法,关闭Linux防⽕墙
centOS6及以前版本使⽤命令:
systemctl stop iptables.service
centOS7关闭防⽕墙命令:
systemctl stop firewalld.service
报错 403 Forbidden
nginx 错误⽇志如下
这个问题解决⽅法很多,这⾥选择其中⼀种
编辑f⽂件
⾸⾏ user 的 nobody 改为 root,或者其他有权限的⽤户名
重启nginx
成功界⾯
配置nginx打印响应和请求报⽂⽇志f ⽂件配置如下
worker_processes 1;
events {
worker_connections 1024;
}
http {
include pes;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#log_format main '$request_body'
log_format main escape=json '请求报⽂:$request_body | 响应报⽂:"$resp_body"'; #access_log logs/access.log main;
nginx和网关怎么配合使用sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
charset koi8-r;
set $resp_body "";
access_log logs/host.access.log main;
location /{
root html;
index index.html index.htm;
}
location /sendAndForward {
proxy_pass ........:8082/sendAndForward;
lua_need_request_body on;
body_filter_by_lua '
local resp_body = string.sub(ngx.arg[1],1,1000)
if ngx.arg[2] then
sp_body = buffered
end
';
}
error_page 500502503504/50x.html;
location =/50x.html {
root html;
}
}
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论