gpt4 book ai didi

nginx - 如何通过 Nginx 注入(inject)自定义内容?

转载 作者:行者123 更新时间:2023-12-03 10:14:30 25 4
gpt4 key购买 nike

有没有办法为每个服务的 php/html/etc 注入(inject)几行脚本等。页?
例如 -tag 之后的一些自定义 javascript?

我知道,你应该可以在 nginx 中使用 lua,但是有更好的解决方案吗?

我在 nginx 后面运行多个不同的 web 应用程序,所以感觉这样做是正确的方法。我无法访问每个应用程序的源代码,维护它们会很麻烦。

最佳答案

我找到了这样做的方法:http://nginx.org/en/docs/http/ngx_http_sub_module.html

location / {
sub_filter </head>
'</head><script language="javascript" src="$script"></script>';
sub_filter_once on;
}

关于nginx - 如何通过 Nginx 注入(inject)自定义内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19700871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com