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)

}

相关推荐
higherzjm2 天前
如何通过Linux命令自动切割nginx和redis日志
linux·redis·nginx
l1t2 天前
用李红艳先生的DuckDB luajit插件批量计算数独
数据库·sql·lua·duckdb
小张同学a.3 天前
zabbix企业级监控平台3——服务监控与API实战
linux·运维·mysql·nginx·tomcat·zabbix
Archy_Wang_13 天前
LVS+KeepAlived+Nginx实现企业级业务高可靠部署的实战教程
运维·nginx·lvs
Ai拆代码的曹操3 天前
Nginx upstream keepalive 连接池中毒排查实录
chrome·nginx·php
空谷有来人4 天前
Ubuntu22.04上安装配置站点
nginx
PC2005-cloud4 天前
KubeSphere学习笔记:部署nginx
笔记·学习·nginx
后除4 天前
Debian 安装与使用 Certbot
后端·nginx·https
风雨_834 天前
轻量级 Nginx 日志分析和可视化平台 NginxPulse安装
运维·nginx
若无情我 纸小铭4 天前
Nginx学习笔记(二) Nginx--connection&request
笔记·学习·nginx