【发布时间】:2013-11-11 03:00:50
【问题描述】:
有没有办法为每个服务的 php/html/etc 注入几行脚本等。页? 例如 -tag 之后的一些自定义 javascript?
我知道,你应该可以在 nginx 中使用 lua 但有更好的解决方案吗?
我在 Nginx 后面运行多个不同的 Web 应用程序,所以感觉这样做是正确的方法。我无法访问每个应用程序的源代码,维护它们会很麻烦。
【问题讨论】:
标签: nginx code-injection
有没有办法为每个服务的 php/html/etc 注入几行脚本等。页? 例如 -tag 之后的一些自定义 javascript?
我知道,你应该可以在 nginx 中使用 lua 但有更好的解决方案吗?
我在 Nginx 后面运行多个不同的 Web 应用程序,所以感觉这样做是正确的方法。我无法访问每个应用程序的源代码,维护它们会很麻烦。
【问题讨论】:
标签: nginx code-injection
我找到了方法: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 -V,它“将列出所有配置的模块”(Source)并寻找--with-http_sub_module。
proxy_set_header Accept-Encoding "";,它告诉后端在响应中不允许压缩。
head开头注入base,head可以包含一些我事先不知道的属性?