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)

}

相关推荐
tryCbest10 小时前
Vue3项目在Nginx中配置代理后端IP
nginx·vue3
就叫飞六吧11 小时前
DeepSeek Harness 本地安装与启动指南
nginx
難釋懷17 小时前
Nginx主动健康检查
运维·nginx
重庆小透明18 小时前
深入探寻微服务【第五篇微服务限流实战】
微服务·junit·架构
難釋懷1 天前
Nginx-Openresty
nginx·junit·openresty
qetfw1 天前
Debian 部署 Discuz! 论坛:Nginx、PHP 与 MariaDB 配置
linux·运维·nginx·debian·php·discuz
CDN3601 天前
大文件分发排坑:出海手游 APK 下载中断、速度慢,CDN 预热与后端 Nginx 优化方案
运维·前端·nginx·网络优化·大文件分发
記億揺晃着的那天1 天前
NAS 内网域名访问为什么需要浏览器授权
网络·nginx·js·nas
小努蛋2 天前
linux编译openresty异常问题,lua_cjson.c:706:5: 错误: ‘for‘ 循环初始化声明只在 C99 或 C++ 模式下允许
开发语言·lua·openresty
骇客野人2 天前
基于Nginx+Eureka+Apollo+Jenkins+SpringBoot Web系统分布式部署方案
nginx·eureka·jenkins