Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to activate gzip #493

Closed
scaccogatto opened this issue Sep 25, 2018 · 14 comments
Closed

unable to activate gzip #493

scaccogatto opened this issue Sep 25, 2018 · 14 comments
Assignees

Comments

@scaccogatto
Copy link

scaccogatto commented Sep 25, 2018

With my system:

| (Ingress) 
| Google Cloud Load Balancer 
|--------> Website Backend
|--------> Website Backend
|--------> Website Backend
|--------> Website Backend

Ingress config: https://gist.github.com/scaccogatto/8796908c22cc6437fc645f3fba587edd
Backend nginx config: https://github.com/scaccogatto/vue-nginx/blob/master/docker/nginx.conf

Following:
https://cloud.google.com/load-balancing/docs/https/setting-up-https#compression-not-working

As you can see from my configs gzip directives are here, also I found that my Request Headers contains accept-encoding: gzip, deflate, br.

Unfortunately when I run Chrome's audit it says that I should enable text compression even if most of online gzip checkers say that gzip is active (but I don't trust them)

Also I found that my Response Headers does not contain: content-encoding: gzip so I assume gzip is not working correctly.

Searching on the net I found this: https://stackoverflow.com/a/48084669/10412176 (that actually says the same things that's on the docs) and I am starting to think than I am changing the wrong configuration and the docs reefer to the Ingress configuration (that is not reachable as fas as I know)

I don't really know if it is a bug or not so I'm asking here.

@rramkumar1
Copy link
Contributor

@scaccogatto This looks like an Nginx specific issue. Going to close this.

Feel free to re-open if you think this is an Ingress-GCE issue.

/close

@k8s-ci-robot
Copy link
Contributor

@rramkumar1: Closing this issue.

In response to this:

@scaccogatto This looks like an Nginx specific issue. Going to close this.

Feel free to re-open if you think this is an Ingress-GCE issue.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@scaccogatto
Copy link
Author

Sorry but this is not a Nginx issue. The fact that you cannot enable gzip with Ingress-GCE is a Ingress-GCE issue not an nginx one.
I just switched to Ingress-Nginx for my production env and it was super easy to enable gzip but the problem remains, gzip is a widely used feature and I feel like not implementing it into Ingress-GCE makes it unusable for web oriented projects.

So this confirm this is actually not a bug but a missing feature I suppose.

@rramkumar1
Copy link
Contributor

@scaccogatto

You said: "Response Headers does not contain: content-encoding: gzip"

Unless I am misunderstanding your setup, doesn't this mean your application needs to return the proper headers?

@bowei bowei reopened this Oct 9, 2018
@bowei
Copy link
Member

bowei commented Oct 9, 2018

Can you post your HTTP request and response headers?

@scaccogatto
Copy link
Author

@scaccogatto

You said: "Response Headers does not contain: content-encoding: gzip"

Unless I am misunderstanding your setup, doesn't this mean your application needs to return the proper headers?

@rramkumar1 My application does return the proper headers, in fact, if I run the same application under a Ingress-Nginx (setting the right annotations), gzip works as expected with no configuration edit.

Can you post your HTTP request and response headers?

@bowei I can't. I am working on a company cloud and I am not planning to enable another load balancer very soon but you can refer to:

I found that my Request Headers contains accept-encoding: gzip, deflate, br.

and

my Response Headers does not contain: content-encoding: gzip

I hope this is enough

@bowei
Copy link
Member

bowei commented Oct 10, 2018

@scaccogatto can you post an anonymized subset of headers? This setup should be easy to repro if we have that information.

@rramkumar1
Copy link
Contributor

ping @scaccogatto

@scaccogatto
Copy link
Author

You can repro it with this kind of configuration:
Pod with nginx serving files -> Ingress (GCE) with all standard things -> content is not gzipped.
The same configuration using Ingress-Nginx instead of GCE works perfectly.

I am sorry I am not starting another GCE Ingress very soon.

@acasademont
Copy link

GCLB will NOT compress backend responses, It's a known "feature", while Nginx is capable of doing so. I believe this is what @scaccogatto would want, that GCLB were able to compress non-compressed backend responses. There's a petition for GCLB to implement that.

https://googlecloudplatform.uservoice.com/forums/302616-load-balancing/suggestions/34129591-enable-gclb-gzip-compression

@AdrianNeatu
Copy link

I think I'm facing the same issue here. And no, @acasademont I don't think that's the problem - I want to use the gzip from nginx not GCLB.
I have an nginx server in a pod with "gzip on" (and the rest of the needed settings).
If I do something like "curl -H "Accept-Encoding: gzip" -I http://localhost:8080" from the pod itself or even from a different pod, I receive the "Content-Encoding: gzip" header. Same if I curl the service.
However, if I curl the "ingress-gce" i don't receive the Header. It's pretty clear that somehow the ingress affects gzip.
Below are the Response Header for each case:
With gzip (when hitting the pod or service directly):
HTTP/1.1 200 OK Server: nginx/1.8.1 Date: Thu, 31 Jan 2019 12:46:39 GMT Content-Type: text/css Last-Modified: Thu, 31 Jan 2019 12:23:06 GMT Connection: keep-alive ETag: W/"5c52e8aa-1a5df" Cache-Control: public, max-age=60 Content-Encoding: gzip

Without gzip (when hitting the ingress):
HTTP/1.1 200 OK Server: nginx/1.8.1 Date: Thu, 31 Jan 2019 12:48:21 GMT Content-Type: text/css Content-Length: 107999 Last-Modified: Thu, 31 Jan 2019 12:23:06 GMT ETag: "5c52e8aa-1a5df" Cache-Control: public, max-age=60 Accept-Ranges: bytes Via: 1.1 google

@rramkumar1
Copy link
Contributor

I'm looking into this deeper. I'm going to see if I can reproduce the issue with a simpler setup.

@rramkumar1 rramkumar1 self-assigned this Apr 17, 2019
@rramkumar1
Copy link
Contributor

rramkumar1 commented Apr 17, 2019

@AdrianNeatu I was unable to reproduce this, albeit with a much simpler setup. I used an echoserver that gzip's the response body and returns the "Content-Encoding: gzip" header when the request header "Accept-Encoding: gzip" is present. The response headers were fine upon a request being made.

Is it possible that your nginx server has some sort of setup that does not compress responses in certain situations?

@rramkumar1
Copy link
Contributor

rramkumar1 commented Apr 17, 2019

Ah I think I found the issue @scaccogatto @AdrianNeatu does the following documentation help?

https://blog.percy.io/tuning-nginx-behind-google-cloud-platform-http-s-load-balancer-305982ddb340

I'm going to close this for now assuming that the fix mentioned there will solve the problem.

/close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants