1

I'm using google cloud Load balancer that sits in front of an nginx backend service (in google cloud terms).

When i'm accessing the nginx server directly i can see the 'Content-Encoding: gzip' header (left side).

But the response from the Load balancer doesn't contain this header (right side).

enter image description here

I've enabled gzip_proxied in my nginx configuration file:

server {

   listen 80;
    gzip on;
    gzip_vary on;
    gzip_proxied any;  // <------ Here
    gzip_types text/plain text/css text/js text/xml text/javascript application/javascript application/x-javascript application/json application/xml application/rss+xml image/svg+xml;

    access_log  /var/log/nginx/access.log;
    error_log   /var/log/nginx/error.log;

    root /usr/share/nginx/html;
    index index.html index.htm;

    location / {
        gzip_static on;
        if ($http_x_forwarded_proto = "http") {
            return 301 https://$host$request_uri;
        }
        try_files $uri $uri/ /index.html;
    }
}

Relevant link that did not worked: https://stackoverflow.com/questions/35947469/google-cloud-http-balancer-and-gzip

Any ideas?

1
1

I post this community wiki answer to make solution more noticeable.

As it was answered by @Mohibul Mahmud at the comment section this question was already answered:

Cloud load balancer does not compress or decompress responses itself. They serve responses generated by the backend instances that are compressed using gzip.You need to enable gzip proxied.

In order to contain this header in the load balancer’s response, in you nginx configuration file, you may have to set up an Accept-Encoding header and modify user agent to contain the string agent as mentioned in this document.

For example:

Accept-Encoding: gzip

User-Agent: my program (gzip)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.