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)

}

相关推荐
難釋懷9 小时前
Nginx虚拟主机
git·nginx·github
前端 贾公子9 小时前
基于 Nginx 实现一个灰度上线系统
运维·nginx
鱼听禅12 小时前
CentOS使用Nginx配置代理Gitea后网址设置正确,确保URL不匹配的问题记录
nginx·centos·gitea
Jinkxs14 小时前
LoadBalancer- 简单限流策略:Nginx 基于连接 / 请求的限流实现
java·运维·nginx
imuliuliang14 小时前
Laravel5.x核心特性全解析
android·运维·数据库·nginx
Re_Virtual1 天前
centos 7环境下构建nginx 1.30
nginx·centos·rpmbuild
tonydf1 天前
Nginx爆新的RCE漏洞!别担心,平滑升级即可。
后端·nginx
曹牧1 天前
Nginx 504
运维·nginx
上海合宙LuatOS1 天前
Air8000多网通信- RNDIS/ECM
物联网·lua·嵌入式开发·多网通信
rockmelodies2 天前
CentOS Stream 源码编译安装 Nginx 1.31.0(静态依赖版)
运维·chrome·nginx