Nginx – How to set gzip_static and gzip_proxied in nginx

gzipnginx

nginx is in front of an application server and functions as the reverse proxy as well as the file server.

There are two types of responses from the application server: JSON messages and X-Accel-Redirect which instructs nginx to deliver static files.

The static files are already pre-compressed, and I want nginx to serve these gzipped content so I've enabled gzip_static on. My question is, how should I set gzip_proxied in this case?

My understanding is that gzip_proxied decides whether responses from the application server will be gzipped while being delivered to the client. In my case, JSON messages do not need to be compressed, and static files are already pre-compressed. Does this mean that I can leave gzip_proxied off?

Best Answer

Yes, you can leave gzip_proxied off if you only want to compress the static files delivered via X-Accel-Redirect

You can set the gzip_static parameter in the location block that the redirect points to