# nginx 注入内容
通过nginx进行反向代理的时候可以通过sub_filter指令进行内容替换、内容注入
location / {
...
sub_filter </head>
'<style>.navbar {display: none;} .chatroom {display: none;}</style></head>';
sub_filter_once on;
...
}
# 注意事项一:
如果被代理的服务返回的是gzip压缩的内容,则上述指令无效,可以通过proxy_set_header Accept-Encoding "";确保被代理的服务返回非压缩内容。
# 注意事项二:
sub_filter 指令由http_sub_module模块提供,nginx默认没有安装,可通过nginx -V查看已安装的模块。