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)

}

相关推荐
.柒宇.6 小时前
运维常见面试题_04_Nginx与DNS服务
运维·nginx·面试·dns
NGINX开源社区7 小时前
NGINX Ingress Controller 5.5:安全性与性能提升,迁移更轻松
java·服务器·nginx
weixin_307779137 小时前
PHP 大文件上传:内存占用、超时与最佳实践
linux·服务器·开发语言·nginx·php
闲云野鹤在人间7 小时前
项目实战:LNMP-电商平台-ECshop
linux·运维·nginx·apache·lvs
暖核7 小时前
Keepalived 高可用全解析:从 VRRP 原理到生产环境 Nginx 主备切换实践
网络·nginx·智能路由器
SatanII1 天前
403 禁地:Nginx 拒绝所有生者进入
运维·nginx
rockey6271 天前
基于AScript的Lua脚本语言发布啦
c#·.net·lua·script·动态脚本
xianyuCcCcCCCcc1 天前
Nginx 深度解析:从基础架构到反向代理与负载均衡实战全解
linux·运维·nginx·bash·负载均衡
冠希陈、1 天前
Nginx部署SSL,导致多站点串站问题
运维·nginx·ssl
AAA@峥1 天前
K8s 流量入口管理|Ingress 核心原理 + ingress-nginx 部署 + 生产实战案例合集
nginx·容器·kubernetes