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)

}

相关推荐
锋行天下14 小时前
中小项目高可用,真的需要K8s吗?从单机备份到企业级架构的完整思考
后端·mysql·nginx
FFZero115 小时前
[mpv脚本系统] (四) 脚本加载与事件循环系统
c语言·音视频·lua·多媒体
多彩电脑1 天前
Lua中的元表里的__index和__newindex
开发语言·lua
辰_砂1 天前
国产服务器操作系统编译nginx生成rpm包
运维·nginx
zfoo-framework2 天前
通过redis-cli+lua脚本查询redis数据
数据库·redis·lua
kiss strong2 天前
自制请求工具
开发语言·python·lua
闪电悠米2 天前
黑马点评-秒杀优化-04_lua_and_db_fallback
服务器·开发语言·网络·数据库·缓存·junit·lua
闪电悠米2 天前
黑马点评-秒杀优化-03_blocking_queue_async_order
数据库·分布式·oracle·junit·wpf·lua
finyouIT2 天前
限制国外ip访问网站
nginx
qq_312920112 天前
高并发防护:Nginx 流量控制
nginx