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.arg1: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.arg1 = ngx.arg1:gsub("</head>", script)

}

相关推荐
云计算磊哥@5 小时前
运维开发宝典058-大型网站nginx服务器管理全集4
服务器·nginx·运维开发
背书包的甜瓜9 小时前
Python Excel转lua配置工具
lua
minglie114 小时前
esp32集成lua
lua
文水爱心帮扶15 小时前
文明劝导暖街头,青春志愿护通行|文水县爱心帮扶志愿者协会开展暑期交通文明活动
junit
番茄炒鸡蛋加糖1 天前
Redis--Lua 脚本原子性与滑动窗口限流
数据库·redis·lua
郝亚军2 天前
使用Vue 3和Nginx打包和部署Vue.js项目的一般步骤
前端·vue.js·nginx
星空露珠2 天前
28种颜色对应名称,
开发语言·数据库·算法·游戏·lua
難釋懷3 天前
Nginx代理https请求
redis·nginx·https