Hello!
On Sun, Jul 21, 2013 at 4:26 AM, Viktor malezink wrote:
> Hello guys, hello agentzh, i still playing with your modules, and now my
> targer is echo module.
> So how to do that?(subj)
> I try this but..
>>
>> if ($content_type = text/html){
>>
>> echo_after_body 'Hello little buddy';
>> }
>
> something wrong.
>
Don't use nginx's if directive wherever possible, which is evil:
http://wiki.nginx.org/IfIsEvil
And another very big problem in your configuration is that you are
trying to configure *two* nginx modules (i.e., ngx_echo and ngx_proxy)
in a single location to serve as the "content handler" (that generates
the "content" and creates the response), which is very very wrong. It
is already common sense that only *one* nginx module can serve as the
"content handler" for a given location otherwise multiple modules will
just conflict with each other.
To be honest, I don't quite understand what exactly you want to
achieve here. Do you want to replace the whole response body with your
own content ("Hello little buddy") if the response header Content-Type
is text/html? That sounds a bit weird to me. But anyway, if that's
what you want, you can achieve the exact effect by using the
header_filter_by_lua and body_filter_by_lua directives in ngx_lua:
http://wiki.nginx.org/HttpLuaModule#header_filter_by_lua
http://wiki.nginx.org/HttpLuaModule#body_filter_by_lua
Alternatively, if you don't have many big responses, you can also use
ngx.location.capture to do fully buffered processing:
http://wiki.nginx.org/HttpLuaModule#ngx.location.capture
> If replace_module have directive replace_filter_types, the echo module
> haven't, or i ain't found them.
I cannot parse this sentence. What role does the ngx_replace_filter
module play here? Will you elaborate?
Best regards,
-agentzh