lua脚本动态插入script标签 在nginx层面

body_filter_by_lua_block{

local pin = ngx.var.cookie_jrapp_jsfGateway_testPin

local domain = ngx.var.host

local scheme = ngx.var.scheme

local title = "白条"

local match = ngx.arg[1]:match("<title>([^<]+)</title>")

if match then

title = match

end

if not pin then

pin = "未知pin"

end

local script = string.format('<script crossorigin=\"anonymous\" src=\"%s://%s/page-spy/index.min.js\"></script><script>window.$pageSpy=new PageSpy({ project: \"%s\", title: \"%s\" })</script></head>', scheme,domain,title, pin)

ngx.arg[1] = ngx.arg[1]:gsub("</head>", script)

}

相关推荐
Dxy12393102164 小时前
Nginx原生配置介绍
运维·nginx
原神启动14 小时前
Docker-compose一键部署设备管理平台 nginx+mysql+springboot
mysql·nginx·docker
岁岁种桃花儿9 小时前
服务SOA化 彻底理解手册(完整版)
nginx
oMcLin9 小时前
Ubuntu 22.04服务器如何配置并调优Nginx负载均衡,支持百万级并发请求?
服务器·nginx·ubuntu
Joy T21 小时前
【AI运维】03 Nginx 配置与内网转发:从访问链路到 proxy_pass 的完整理解【深度好文】
运维·nginx
2501_946675641 天前
Flutter与OpenHarmony打卡动画效果组件
运维·nginx·flutter
_200_1 天前
Lua 运算符
开发语言·junit·lua
_200_1 天前
Lua 基本数据类型
开发语言·junit·lua
print_Hyon1 天前
【CTF-WEB】在线Lua执行器漏洞
lua·ctf
释怀不想释怀1 天前
打包部署(vue前端)(Nginx)
运维·nginx