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)

}

相关推荐
Ai拆代码的曹操7 小时前
Nginx upstream keepalive 连接池中毒排查实录
chrome·nginx·php
空谷有来人16 小时前
Ubuntu22.04上安装配置站点
nginx
PC2005-cloud17 小时前
KubeSphere学习笔记:部署nginx
笔记·学习·nginx
后除17 小时前
Debian 安装与使用 Certbot
后端·nginx·https
风雨_8320 小时前
轻量级 Nginx 日志分析和可视化平台 NginxPulse安装
运维·nginx
若无情我 纸小铭20 小时前
Nginx学习笔记(二) Nginx--connection&request
笔记·学习·nginx
xixingzhe220 小时前
net::ERR_INCOMPLETE_CHUNKED_ENCODING解决
nginx
轻揉小乔 真新人2 天前
使用memc-nginx和srcache-nginx模块构建高效透明的缓存机制
运维·nginx·缓存
月落归舟2 天前
深入浅出:短信验证码登录场景下的 Nginx 负载均衡与 Session 共享
运维·nginx·负载均衡
东荷新绿2 天前
【运维开发】acme.sh 安装|签发泛域名SSL证书,宝塔Nginx部署+自动续期
nginx·腾讯云·运维开发·ssl·宝塔·acme.sh