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)

}

相关推荐
凡尘——雨落凡尘11 小时前
PHP 线上十大隐形故障复盘:90% 的网站卡顿、502、雪崩,都是这些细节导致的
redis·nginx·php·session
Deryck_德瑞克13 小时前
【Nginx】配置差异分析
服务器·前端·nginx
学者猫头鹰20 小时前
Nginx零基础学习手册
nginx
qq_370773091 天前
Unity游戏xLua逆向实战:从SO版本识别到Lua脚本热替换全链路
游戏·unity·lua
難釋懷2 天前
Nginx外置缓存-nginx + memcached
nginx·缓存·memcached
難釋懷2 天前
Nginx外置缓存-nginx + redis
redis·nginx·缓存
☆凡尘清心☆3 天前
CentOS Stream 9 专用 LNMP 全自动一键脚本
linux·运维·mysql·nginx·lnmp·centos stream 9
山城码农笑松哥3 天前
Redis 8.8 新特性实操笔记:原生数组、INCREX 限流、XNACK 流处理
redis·笔记·junit
似的8353 天前
一步一步学习使用FireMonkey动画() 使用TAnimator类创建动画
linux·学习·nginx
Zacks_xdc4 天前
【运维】Nginx 蓝绿部署与流式任务(SSE)不中断架构实战
运维·nginx·架构·nextjs