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.
One more info: I tried many different combinations of “gzip on|off” and
other directives, basically I indiscriminately tried everything I found
mentioned somewhere. But, nothing changed the behavior much as far as I
could see, so I stripped it out of the configuration again for
readability.
location /itunes/raw/ {
suppress proxying for testing completely
proxy_cache off;
getting a json containing N current top albums from itunes
proxy_pass
http://itunes.apple.com/de/rss/topalbums/limit=2/explicit=true/json;
}
location /itunes/echo-after/ {
proxy_cache off;
proxy_pass
http://itunes.apple.com/de/rss/topalbums/limit=2/explicit=true/json;
echo something after body
echo_after_body “);”;
}
location /itunes/echo-before/ {
proxy_cache off;
echo something before body
echo_before_body -n “abc(”;
proxy_pass
http://itunes.apple.com/de/rss/topalbums/limit=2/explicit=true/json;
}
location /itunes/echo-beforeNafter/ {
proxy_cache off;
echo_before_body -n “abc(”;
proxy_pass
http://itunes.apple.com/de/rss/topalbums/limit=2/explicit=true/json;
echo_after_body “);”;
}
</nginx configuration for testing>
You are very welcome to access Home - Ganske.de… if
it may help you assess my problem.
Echo v0.51
</info about my installation>
Any help is greatly appreciated!
Cheers /Carsten
Carsten Germer
Creative Director
intolabs GmbH
http://www.intolabs.net/