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)

}

相关推荐
liuyicenysabel7 小时前
Flask 个人站 iProfile 上线笔记(k3s + Nginx + Let‘s Encrypt)
笔记·nginx·flask
Jimmy_jimi21 小时前
利用nginx代理完成url重定位
运维·nginx
小的~~1 天前
面试被问懵了?为什么 Redis 单线程还能保证 Lua 脚本原子性,却偏偏选了 Lua?
redis·面试·lua
东风破_2 天前
Docker 基础:为什么需要容器?
前端·后端·nginx
东风破_2 天前
Docker 实战:使用 Nginx 作为容器入口代理 Node 服务
前端·后端·nginx
外滩运维专家2 天前
通配符证书到期,阿里云上几个服务的证书怎么一次换完
运维·开发语言·nginx·https·php·消息推送
qq10916069812 天前
nginx+TongWeb 配置非443端口的https
网络·nginx·https
晨曦花锦2 天前
Vim基础操作与Ollama模型管理,顺便配置Nginx反向代理
linux·nginx·编辑器·vim
難釋懷2 天前
Nginx-Lua
nginx·junit·lua
我滴老baby2 天前
多个内网服务怎么统一入口?部署 Nginx Proxy Manager 配置反向代理与 SSL
运维·nginx·ssl