**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
<Files "*.lua">
SetOutputFilter myOutputFilter
</Files>
--[[
Example output filter that escapes all HTML entities in the output
]]--
function output_filter(r)
coroutine.yield("(Handled by myOutputFilter)<br/>\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
<Location "/">
AddOutputFilterByType SUBSTITUTE text/html
Substitute "s/foo/bar/ni"
</Location>
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"
来自:
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