+-------+ +---------> +-----+ +---------> +--------+
|browser| |proxy| |upstream|
+-------+ <---------+ +-----+ <---------+ +--------+
gzipped !gzipped!
Created
August 20, 2016 09:40
-
-
Save KostyaEsmukov/79ed4f2b16eec6bea7acbd948b5c29c6 to your computer and use it in GitHub Desktop.
Setup of two nginx servers, where traffic between upstream and balancer is gzipped.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
# ... the rest of your config | |
location /static/ { | |
# ... the rest of your config | |
gzip off; | |
# proxy_set_header Host $host; | |
# proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header Accept-Encoding $http_accept_encoding; | |
proxy_pass http://upstream; | |
} | |
# ... the rest of your config | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http { # server, location contexts will also work | |
# ... the rest of your config | |
# you can safely not configure gzip on the proxy at all, but if you want to gzip responses other than | |
# those from the upstream - you should these lines in your config | |
gzip on; | |
gzip_disable msie6; | |
gzip_vary on; | |
gzip_proxied any; | |
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; | |
# ... the rest of your config | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http { # server, location contexts will also work | |
# ... the rest of your config | |
gzip on; | |
gzip_disable msie6; | |
gzip_vary on; | |
gzip_proxied any; | |
gzip_http_version 1.0; # this is the most important line, because proxy_pass uses http/1.0 | |
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; | |
# uncomment this if you want to provide nginx already gzipped variants of files, like `${file}.gz` | |
# gzip_static on; | |
# ... the rest of your config | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment