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)

}

相关推荐
陈皮糖..8 小时前
27 届运维实习笔记|第三、四周:从流程熟练到故障排查,企业运维实战深化
运维·笔记·sql·nginx·ci/cd·云计算·jenkins
上海合宙LuatOS10 小时前
LuatOS扩展库API——【libnet】TCP/UDP协议
物联网·tcp/ip·junit·udp·luatos
空中海14 小时前
Nginx 知识体系 · 下篇:高级与实战
运维·nginx·spring
心之所向,自强不息18 小时前
VSCode + EmmyLua 调试 Unity Lua(最简接入 + 不阻塞运行版)
vscode·unity·lua
身如柳絮随风扬19 小时前
Nginx 入门教程:从安装到配置反向代理与负载均衡
运维·nginx·负载均衡
weixin_4080996720 小时前
Lua请求文字识别ocr api
图像处理·人工智能·后端·ocr·lua·api·文字识别
IntMainJhy20 小时前
Flutter flutter_animate 第三方库 动画的鸿蒙化适配与实战指南
nginx·flutter·harmonyos
上海合宙LuatOS1 天前
LuatOS扩展库API——【libfota】远程升级
物联网·junit·lua·luatos
mfxcyh1 天前
使用MobaXterm配置nginx
java·服务器·nginx
阿里巴巴首席技术官1 天前
通过纯Nginx实现一个简单的文件上传功能
运维·nginx