Open itsdax opened 7 months ago
Oh I figured out a way to do this, via proxying through 3 layers. Starting from the third (last layer), it makes the request to the origin with compressing with gzip, then flows back upstream (layer 2) to gunzip, and finally back to layer one to compress with Brotli.
This seems like a hack... so I'll leave this issue open for anyone to tell me how the following code violates the geneva conventions. Please let me know if there's better alternatives.
http {
server {
brotli on;
brotli_comp_level 11;
brotli_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
listen 80;
location / {
proxy_pass http://127.0.0.1:81/;
proxy_http_version 1.1;
}
}
server {
listen 81;
location / {
proxy_pass http://127.0.0.1:82/;
proxy_http_version 1.1;
proxy_set_header Accept-Encoding "";
}
}
server {
listen 82;
gunzip on;
location / {
resolver kube-dns.kube-system.svc.cluster.local;
proxy_pass http://MYSERVICE.default.svc.cluster.local:8080/;
proxy_http_version 1.1;
proxy_set_header Accept-Encoding "gzip";
}
}
}
Hello, I am having trouble figuring out how to configure Nginx to always prefer Brotli over Gzip.
For example, if the request(
Accept-Encoding
:gzip, deflate, br
) is sent to Nginx, and the reverse proxies location handles compression ingzip
, how do I tell Nginx to gunzip content and compress withbrotli
?In the case above, all responses will result in
gzip
compression. However, if the backend does not performgzip
compression, then the response to the original caller would be inbr
.Appreciate any help on this matter. Thanks!