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)

}

相关推荐
开发小程序的之朴10 小时前
认识安企CMS - 系统概述
nginx·golang·系统架构
开开心心_Every10 小时前
带OCR识别的电子发票打印工具
运维·自动化·ocr·电脑·powerpoint·音视频·lua
小蜗牛的路10 小时前
使用OpenSSL生成本地证书https+nginx
网络协议·nginx·https
芷栀夏12 小时前
飞牛NAS怎么部署Immich?家庭照片自动备份与远程访问教程
服务器·nginx·ansible
難釋懷5 天前
Nginx-rsync客户端免密
运维·nginx
Avan_菜菜12 天前
FRP 内网穿透完整实战:从 HTTP 映射到 HTTPS 自签代理
运维·nginx·https
ping某16 天前
为什么 Nginx 明明监听了 80,转发后端时却用了 4xxxx 端口?
后端·nginx
许彰午18 天前
39_Java单元测试JUnit入门
java·junit·单元测试
xingpanvip18 天前
星盘接口开发文档:本命盘接口指南
android·开发语言·css·php·lua
難釋懷18 天前
Nginx反向代理中的容错机制
运维·nginx