Reputation: 175
Dose nginx supprt this ? Whoul you please show me some configuration of it?
[Client] [Nginx Reverse Proxy] [BackEnd]
| [Raw Post] | [gzip encoded request] |
|--------------------> | ----------------------------->|
| | |
| [Raw Response] | [gzip encoded response] |
| <------------------ | <-----------------------------|
| | |
Upvotes: 7
Views: 9686
Reputation: 29579
The full and correct answer is that nginx can do this, but with a couple of caveats. In order to provide an uncompressed response to the edge client (user PC), you must compile nginx with the gunzip
module - which isn't built/included by default. This is the opposite of the gzip module, and allows nginx to unzip already-compressed resources found on disk or obtained from a backend server.
So when compiling nginx, include this:
--with-http_gunzip_module
And in your nginx.conf
, you'll have a block like this to describe requests to be obtained from a backend server:
location @backend {
...
proxy_pass http://10.0.0.xxx;
gunzip on;
proxy_set_header Accept-Encoding "gzip";
}
Upvotes: 2
Reputation: 46350
Apparently there is some way to do this. Nginx has a gunzip
module that gzip decompresses responses:
The ngx_http_gunzip_module module is a filter that decompresses responses with “Content-Encoding: gzip” for clients that do not support “gzip” encoding method. The module will be useful when it is desirable to store data compressed, to save space and reduce I/O costs.
This module is not built by default, it should be enabled with the --with-http_gunzip_module configuration parameter.
Source: http://nginx.org/en/docs/http/ngx_http_gunzip_module.html
Then you can use it like:
gunzip on;
Hope that works for you.
Also see this SO question: Is there sort of unzip modules in nginx?
Upvotes: 4
Reputation: 46350
You can turn off gzip compression in nginx by setting the gzip
directive to off
in your nginx.conf
:
gzip off
Additionally you can turn of gzip compression for proxied requests only:
gzip_proxied off
Nginx has a great wiki where all this information is clearly explained: http://wiki.nginx.org/HttpGzipModule
About nginx proxying: also clearly described in the nginx wiki:
Example:
location / { proxy_pass http://localhost:8000; proxy_set_header X-Real-IP $remote_addr; }
http://wiki.nginx.org/HttpProxyModule
There are many different ways to set up a proxy so you should dive in and see what you need exactly, there's no 'one' answer to this.
Upvotes: 1