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)

}

相关推荐
Filotimo_10 小时前
Nginx 的概念
运维·nginx
大雨淅淅11 小时前
【开发工具】Postman从入门到精通:环境搭建与使用全攻略
开发语言·lua
爱学习的潇潇11 小时前
Postman学习之常用断言
自动化测试·软件测试·功能测试·学习·程序人生·lua·postman
程序员雷叔11 小时前
在postman设置请求里带动态token,看看这两种方法!
selenium·测试工具·单元测试·测试用例·pytest·lua·postman
AI软件工程实践11 小时前
软件工程里 Postman 的文件上传与下载测试技巧
测试工具·ai·lua·postman
IMPYLH15 小时前
Lua 的 Table 模块
开发语言·笔记·后端·junit·游戏引擎·lua
科技块儿16 小时前
如何编程调用IP查询API?(PythonJava等示例)
网络协议·tcp/ip·lua
Shi_haoliu1 天前
SolidTime 在 Rocky Linux 9.5 上的完整部署流程
linux·运维·nginx·postgresql·vue·php·laravel
AI_56781 天前
Postman接口测试极速入门指南
开发语言·人工智能·学习·测试工具·lua
zhengxianyi5151 天前
vue-cli build, vite build 生产部署刷新或弹窗404,页面空白修复方法
前端·javascript·vue.js·nginx·生产部署