How to Enbale gzip for Proxied App in Nginx Sep 27th 2021 Words: 91

Problem

I have added the gzip on; in the nginx configuration file, but all response from apps behind proxy_pass are not gzipped, wasting precious bandwidth of the server.

Solution

Add the following content to the server block (or global):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
gzip  on;
gzip_proxied any;
gzip_types
text/css
text/javascript
text/xml
text/plain
text/x-component
application/javascript
application/json
application/xml
application/rss+xml
font/truetype
font/opentype
application/vnd.ms-fontobject
image/svg+xml;

References