服务器响应方式,整理:web服务器改写响应内容的方式

**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

lua模块使用:

LuaOutputFilter myOutputFilter "/www/filter.lua" output_filter

SetOutputFilter myOutputFilter

--[[

Example output filter that escapes all HTML entities in the output

]]--

function output_filter(r)

coroutine.yield("(Handled by myOutputFilter)

\n") -- Prepend some data to the output,

-- yield and wait for buckets.

while bucket do -- For each bucket, do...

local output = r:escape_html(bucket) -- Escape all output

coroutine.yield(output) -- Send converted data down the chain

end

-- No more buckets available.

end

mod_substitute:

Example

AddOutputFilterByType SUBSTITUTE text/html

Substitute "s/foo/bar/ni"

Rewriting URLs embedded in proxied content

ProxyPass        "/blog/" "http://internal.blog.example.com/"

ProxyPassReverse "/blog/" "http://internal.blog.example.com/"

Substitute "s|http://internal.blog.example.com/|http://www.example.com/blog/|i"

来自:

https://serverfault.com/questions/789743/possibility-of-rewriting-response-bodies-in-different-webservers-nginx-apache

mod_substitute:

http://httpd.apache.org/docs/2.4/mod/mod_substitute.html

lua使用:

http://httpd.apache.org/docs/current/mod/mod_lua.html#luaoutputfilter

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值