Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selectively disable compression based on the incoming request. Fixes #10377 #10378

merged 2 commits into from Jan 11, 2019


Copy link

@georgyberdyshev georgyberdyshev commented Dec 14, 2018

Hello @benjamn,

this a PR to fix #10377

Currently Auto-compress forces gzip compression, that cannot be disabled and therefore interferes with the possibility to enable a different Content-Encoding on a frontend-proxy.

Adding an environment variable to disable Auto-compress will allow to use Brotli compression through a front-end proxy, such as nginx, and provide better compression ratio than gzip.


For more details, please see:

Thanks, Georgy

Copy link

benjamn commented Dec 21, 2018

@georgyberdyshev We're open to this solution (since it will solve your use case), but I was just wondering if your nginx proxy is stripping/disabling the Accept-Encoding header before forwarding the request to the Meteor server? Ideally the Meteor server (i.e. the compress() middleware) would honor (the absence of) that header, rather than blindly compressing everything. Alternatively/additionally, we could configure the compression middleware with a filter that would selectively disable compression based on the incoming request.

Copy link
Contributor Author

georgyberdyshev commented Dec 21, 2018

Hello @benjamn,

thank you for your reply. Meteor behind the nginx proxy correctly receives the Accept-Encoding request HTTP header:

nginx log: - - [21/Dec/2018:17:40:51 +0000] "GET /headers HTTP/2.0" 200 595 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.28 Safari/537.36" "-" "gzip, deflate, br"


{ 'x-forwarded-host': 'localhost',
  'x-forwarded-proto': 'http',
  'x-forwarded-port': '80',
  'accept-language': 'en-US,en;q=0.9',
  'accept-encoding': 'gzip, deflate, br',
  accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
  'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.28 Safari/537.36',
  'upgrade-insecure-requests': '1',
  'cache-control': 'max-age=0',
  'x-no-compression': 'x-no-compression',
  connection: 'close',
  host: 'localhost',
  'x-forwarded-for': ',' }

I have updated the PR to use the x-no-compression HTTP request header, as this will provide more granularity and also makes an additional environment variable for Meteor obsolete.

Thanks, Georgy

@georgyberdyshev georgyberdyshev changed the title Added METEOR_DISABLE_AUTO_COMPRESS environment variable. Fixes #10377 Selectively disable compression based on the incoming request. Fixes #10377 Dec 21, 2018
Setting the x-no-compression request header disables compression.
Co-Authored-By: georgyberdyshev <>
@benjamn benjamn merged commit 5d43d2c into meteor:release-1.8.1 Jan 11, 2019
Copy link
Contributor Author

Thanks @benjamn !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

3 participants