Reverse Proxy Advanced Topics
[ 114 ]
Besides on-the-fly compression of responses, NGINX is capable of delivering
precompressed files, using the gzip_static module. This module is not compiled
by default, but can be enabled with the --with-http_gzip_static_module
compile-time switch. The module itself has one directive, gzip_static, but also
uses the following directives of the gzip module in order to determine when to
check for precompressed files:
- gzip_http_version
- gzip_proxied
- gzip_disable
- gzip_vary
In the following configuration, we enable delivery of precompressed files if the
request contains an Authorization header and if the response contains one of
the Expires or Cache-Control headers disabling caching:
http {
gzip_static on;
gzip_proxied expired no-cache no-store private auth;
}
Summary
We have seen in this chapter how NGINX can be used effectively as a reverse
proxy. It can act in three roles, either individually or in some combination, which
are to enhance security, to enable scalability, and/or to enhance performance.
Security is achieved through separation of the application from the end user.
NGINX can be combined with multiple upstream servers to achieve scalability.
The performance of an application relates directly to how responsive it is to a
user's request. We explored different mechanisms to achieve a more responsive
application. Faster response times mean happier users.
Up next is an exploration of NGINX as an HTTP server. We have so far only
discussed how NGINX can act as a reverse proxy, but there is so much more
that NGINX is capable of.