![可以在不同的网络服务器(nginx、apache、iis 等)中重写响应主体。](https://linux22.com/image/686379/%E5%8F%AF%E4%BB%A5%E5%9C%A8%E4%B8%8D%E5%90%8C%E7%9A%84%E7%BD%91%E7%BB%9C%E6%9C%8D%E5%8A%A1%E5%99%A8%EF%BC%88nginx%E3%80%81apache%E3%80%81iis%20%E7%AD%89%EF%BC%89%E4%B8%AD%E9%87%8D%E5%86%99%E5%93%8D%E5%BA%94%E4%B8%BB%E4%BD%93%E3%80%82.png)
我正在对常用 Web 服务器之间的差异进行个人研究。对于特定功能,以及对我来说最重要的功能,我很难找到明确的答案:重写响应的能力身体在飞行中。
设想:部署一个Web服务器(apache、nginx、iis、varnish、haproxy)作为反向代理或者应用服务器代理(以nginx-->passenger为例)。
问题:在哪些 Web 服务器中以及如何重写响应主体。对此类操作的简易性和性能的 1 或 2 条评论也会很有帮助。
我的研究:
Content rewritting:
Nginx: ngx_http_sub_module
Nginx: LUA body_filter: https://groups.google.com/forum/embed/#!topic/openresty-en/Gj-s_hARc84
Apache: mod_substitute
Apache: starting from 2.3 LUA can be used as a scripting language (and the response body rewriting with it is possible)
IIS: does not seem top be possible?
Varnish: possible, but hacky: https://github.com/aivarsk/libvmod-rewrite
HAproxy: not possible, although it might be possible with LUA in the future
还有什么我忘记的吗?谢谢。
答案1
最终得到这张表:
**Nginx**: ngx_http_sub_module --> http://p.defau.lt/?A6UukYFKZrYLalJ5KOuTKg
**Nginx**: Nginx + lua. LUA body_filter --> http://p.defau.lt/?0ZxLWENoEkFIRD17QlEtbQ
**Apache**: Apache Module mod_substitute --> http://p.defau.lt/?IS8u2mnAQTSHs4qEl_MSFQ
**Apache**: As of version 2.3 LUA can be used as a scripting language for Apache. Response body rewriting is possible there as well. --> http://p.defau.lt/?tTAqWfA8sezQZkmvI3LnFw
**Varnish**: Possible, but hacky: https://github.com/aivarsk/libvmod-rewrite
**HAproxy**: Not possible. Might be possible with LUA in the future