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)

}

相关推荐
困惑阿三3 分钟前
Nginx 域名绑定与 HTTPS 配置指南
运维·nginx·https·ssl
爱莉希雅&&&1 小时前
Ansible+Docker案例(含ansible配置安装docker)
linux·运维·mysql·nginx·docker·容器·ansible
舰长1153 小时前
nginx常用配置反向代理配置
运维·websocket·nginx
空中海5 小时前
Nginx 知识体系 · 上篇:基础与核心
运维·nginx
咚为6 小时前
从Nginx到Pingora?从 Cloudflare 的架构演进讲起
运维·nginx·架构
hERS EOUS15 小时前
nginx 代理 redis
运维·redis·nginx
Wy_编程21 小时前
nginx测试
服务器·nginx
Harvy_没救了1 天前
【Linux】Nginx - 反向代理
linux·运维·nginx
铭keny1 天前
【Ubuntu部署】人脸特征提取SDK完整部署教程(含Nginx代理+问题排查)
linux·nginx·ubuntu
IT 行者1 天前
FastDFS 防盗链详解:Token验证+Nginx白名单保姆级配置指南
运维·nginx