Closed ErwannRobin closed 3 years ago
Ok, I manage to make it work by deactivating the "response-transformer" plugin. Any idea what is the link between those 2 things ?
What does "BC" means ?
@diwann just labels we use to track issues infernally...
we are actively looking at the gzipping questions for Kong.
@thefosk @Tieske can this be closed or we waiting for 0.9.0 release?
This is caused when the plugin tries to access the body of the request/response, and it's unable to read it because it's gzipped.
@Diwann what plugin configuration did you have for the Response Transformation plugin?
I have the following settings:
curl 'https://kong.XXXX/plugins' -X PUT -H 'Content-Type: application/json' --data '{"api_id":"XXXXX-7edf-41dd-9115-16f0e324c882","name":"response-transformer","config":{"remove":{"json":"links"}}}'
However, I haven't checked yet if it's still the case with Konk 0.9
Yes, I just checked, and it's still the case with 0.9.0 (and "next")
ok, I finally found a solution: in order to access to the json structure, the response-transformer plugin need to access the body of the response from the backend. But this body is compressed as soon as the client accept gzip encoding. So the trick is to make Kong and the backend to communicate in plain text, and to handle the gzip compression on Nginx side. For that, you need to hide the "Accept-Encoding" header when the query come in, which you can do in the nginx configuration file, under the "location /" section, with:
proxy_set_header Accept-Encoding "";
Then, you need to activate the gzip compression on nginx side, under the "server" section, with:
gzip on;
gzip_types text/plain application/json;
🎉
@Diwann thx for reporting back with the solution you found!
This is great - @Diwann if you submit a PR I will be happy to tweak and merge it.
A variation to @Diwann 's suggestion for the nginx side from https://github.com/Kong/kong/issues/1200#issuecomment-257940259 is to use the request-transformer
plugin on the Kong side and replace the Accept-Encoding
header to force Accept-Encoding:identity
. By the way, the outbound compression is still not available as per https://github.com/Kong/kong/issues/409
ok, I finally found a solution: in order to access to the json structure, the response-transformer plugin need to access the body of the response from the backend. But this body is compressed as soon as the client accept gzip encoding. So the trick is to make Kong and the backend to communicate in plain text, and to handle the gzip compression on Nginx side. For that, you need to hide the "Accept-Encoding" header when the query come in, which you can do in the nginx configuration file, under the "location /" section, with:
proxy_set_header Accept-Encoding "";
Then, you need to activate the gzip compression on nginx side, under the "server" section, with:
gzip on; gzip_types text/plain application/json;
🎉
I have the nginx-kong.conf file with 3 server blocks kong, kong_gui, kong_admin
i have to add proxy_set_header Accept-Encoding "";
in server_name kong location / block ?
when i restart the kong it overrides those directive, i see the kong.conf have a nginx inject block but i didn't find a way to inject in location / block
Probably a newbie question here, but I am struggling with it for 2 days and can't find the answer...
So: I can't manage to make Kong accept the "Accept-Encoding: gzip" header. Whenever I make a request with the "Accept-Encoding: gzip" header, I have a correct 200 OK status, but my answer is empty ... And gzip on the openresty nginx server seems already activated as it already answer "Accept-Encoding: gzip" in the response header...
The problem is that this header is automatically set by browsers, so I can't demo my API if I setup a Kong proxy. So how to make Kong accept (or ignore) this header ?