Issue
I have nginx reverse proxy that receives brotli compressed response from upstream (Varnish cache). But, the reverse proxy serves brotli compressed response to browser only if I setup "brotli on;" within the reverse proxy server block.
My goal is to have the nginx reverse proxy not handle compression at all. To achieve this, I have following questions:
Is the reverse proxy block expected to un-compress the received response and handle it on it's own? Can't it directly pass the upstream response back to client?
Is there a way to dump proxy response or it's size to nginx logs? This shall help debug the issue better.
Solution
I have resolved this so posting this for anyone who may encounter similar issue:
- Varnish changed my 'Accept-Encoding' request header to 'gzip'. According to Varnish documentation, this is as designed (see here).
- However, the upstream nginx server (behind varnish) responded with non-compressed content because the default for
gzip_http_version
is 1.0 while the default forproxy_http_version
is 1.1. (see here)
Resolution was achieved by:
a. setting Varnish to not worry about compression by passing -p http_gzip_support=off
to varnishd
.
b. setting gzip_http_version
to 1.1
on the upstream Nginx server.
Deciphering the above behavior became possible because I logged the following on my upstream nginx server (the one behind varnish):
log_format bytes_sent '$bytes_sent' - '$http_accept_encoding' - '$request';
Answered By - Punit S Answer Checked By - David Goodson (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.