problem with echo_before when proxying a server which sends gzipped content

Maxim Dounin mdounin at mdounin.ru
Wed Apr 2 13:46:59 UTC 2014


Hello!

On Wed, Apr 02, 2014 at 02:48:33PM +0200, Carsten Germer wrote:

> Hi everyone,
> currently I'm, trying to configure NGINX as a proxy for JSON 
> from the iTunes API.
> It's for a small game, iTunes is slow sometimes and the data for 
> the game is mostly the same for a good length of time, anyway.
> The JSON from iTunes is to be padded with the original requests 
> callback parameters. For this there are many good posts out on 
> the net, but I can't seem to get the basic echo_* to work.
> 
> I boiled my configuration of nginx down to the point where I 
> just use echo_before or echo_after and proxy_pass.
> 
> If I append something with echo_after it works fine in browsers 
> and in jQuery.
> If I prepend anything with echo_before the answer can't be read 
> by browsers, "curl --compressed" throws "curl: (23) Error while 
> processing content unencoding: invalid block type".
> 
> If I configure Firefox with "about:config" to 
> "network.http.accept-encoding:true" it fixes fixes display in 
> Firefox.
> 
> When I look in the network tab of chrome console I see that 
> requesting ".../echo-after/" closes the request after 2Xms.
> Requesting ".../echo-before" also gets 200 ok but never arrives 
> fully, is shown as "pending" indefinitely.
> 
> My best bet is, that it has something to do with gzip-compressed 
> answer from iTunes but I can't find any solution or even hint 
> for my level of understanding of the inner workings of nginx.

Something like

    proxy_set_header Accept-Encoding "";

in relevant location should help.

BTW, you may try add_before_body / add_after_body as available in 
standard addition filter module instead, see here:

http://nginx.org/en/docs/http/ngx_http_addition_module.html

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx mailing list