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.arg[1]: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.arg[1] = ngx.arg[1]:gsub("</head>", script)

}

相关推荐
t***44233 小时前
CORS:跨域访问、如何在Nginx中配置允许跨域访问
运维·nginx
rfidunion4 小时前
springboot+VUE+部署(11。Nginx)
linux·vue.js·nginx
zlpzpl5 小时前
Linux系统下安装配置Nginx(保姆级教程)
java·linux·nginx
匀泪8 小时前
云原生(nginx实验(1))
nginx·云原生
梦白.9 小时前
基于keepalived和lvs的Web集群项目
nginx·运维开发·prometheus·lvs
盛夏绽放1 天前
流式响应 线上请求出现“待处理”问题
前端·后端·nginx·proxy
%251 天前
Nginx
运维·nginx
坤虫debug1 天前
Nginx 模块和指令的区别:http/server/location 不是模块,是指令
nginx
wfj1261 天前
服务器部署,用 nginx 部署后页面刷新 404 问题,宝塔面板修改(修改 nginx.conf 配置文件)
运维·服务器·nginx
匀泪1 天前
云原生(nginx环境设定)
java·nginx·云原生