If this doesn't work you need to use Lua,
http://stackoverflow.com/questions/26436891/nginx-lua-modify-html-response-after-proxy-pass
http://stackoverflow.com/questions/26436891/nginx-lua-modify-html-response-after-proxy-pass