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)

}

相关推荐
ReaF_star1 小时前
【安全】SSL证书更新操作手册(Nginx+Cloudflare+acme.sh)
nginx·安全·ssl
云动课堂3 小时前
【运维实战】Nginx 高性能Web服务 · 一键自动化部署方案 (适配银河麒麟 V10 / openEuler / CentOS 7/8)
运维·前端·nginx
Dylan的码园4 小时前
Maven基础架构与整体认识
java·junit·maven
xingpanvip8 小时前
星盘接口开发文档:日运语料接口指南
android·开发语言·前端·css·php·lua
2601_9498179210 小时前
nginx 代理 redis
运维·redis·nginx
java1234_小锋10 小时前
解释一下NGINX的反向代理和正向代理的区别?
运维·nginx
xingpanvip1 天前
星盘接口开发文档:星相日历接口指南
android·开发语言·前端·css·php·lua
techdashen1 天前
Cloudflare 为何抛弃 NGINX,用 Rust 自研了一个代理
运维·nginx·rust
人生匆匆1 天前
通过nginx解决跨域问题
运维·nginx
子木HAPPY阳VIP1 天前
信创UOS,Docker 完整操作部署(Dockerfile部署方式)&排错整合
linux·运维·redis·nginx·docker·容器·tomcat