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)

}

相关推荐
yzx99101311 小时前
懒人精灵进阶版
junit
武器大师7213 小时前
实战踩坑:Gerrit HTTP 克隆失败解决方案
运维·nginx·gerrit
Plastic garden16 小时前
Docker Compose 的 RuoYi nginx exporter Prometheus + Alertmanager + 钉钉告警
nginx·docker·prometheus
一个儒雅随和的男子16 小时前
Nginx底层原理介绍
运维·nginx
小悟空16 小时前
[AI 生成] Nginx 502 Bad Gateway 排查手册(Python 后端篇)
python·nginx·gateway
Anthony_23116 小时前
Linux 从基础操作到故障排查
linux·运维·服务器·网络·nginx·ubuntu·centos
garmin Chen16 小时前
Prompt工程入门:让AI按你的要求工作(1)--prompt概述与设计
java·人工智能·python·junit·prompt·agent
唐装鼠1 天前
Nginx + Gunicorn + Python Web 应用 架构(Claude)
python·nginx·gunicorn
xingpanvip1 天前
星盘接口开发文档:马盘次限盘接口指南
android·开发语言·python·php·lua
難釋懷1 天前
Nginx扩容
运维·nginx