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)

}

相关推荐
困惑阿三1 天前
客户消息及时反馈
nginx·node.js·飞书·企业微信
liurunlin8881 天前
httpslocalhostindex 配置的nginx,一刷新就报404了
运维·nginx
BullSmall1 天前
Nginx负载均衡会话保持配置指南
运维·nginx·负载均衡
你才是臭弟弟1 天前
Nginx部署前后端
运维·nginx
红黑色的圣西罗1 天前
Lua和C#交互探究记录
c#·lua·交互
_下雨天.2 天前
Nginx性能调优与深度监控
运维·nginx
weiwx832 天前
Nginx location 和 proxy_pass 配置详解
服务器·网络·nginx
向往着的青绿色2 天前
雷池(SafeLine)社区版免费部署教程|从环境检查到防护实操全流程
网络·计算机网络·nginx·网络安全·容器·网络攻击模型·信息与通信
分享牛2 天前
Operaton入门到精通23-Operaton 2.0 原生支持 JUnit 6 核心指南
数据库·junit