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
merged 2 commits into from Jan 11, 2019

Conversation

@georgyberdyshev
Copy link
Contributor

@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.

METEOR_DISABLE_AUTO_COMPRESS=1

For more details, please see:
#10377

Thanks, Georgy

@benjamn
Copy link
Member

@benjamn 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.

@georgyberdyshev
Copy link
Contributor Author

@georgyberdyshev 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:
10.0.2.2 - - [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"

Meteor:

{ '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': '10.0.2.2,127.0.0.1' }

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.
packages/webapp/webapp_server.js Outdated Show resolved Hide resolved
Co-Authored-By: georgyberdyshev <georgyberdyshev@users.noreply.github.com>
@benjamn benjamn merged commit 5d43d2c into meteor:release-1.8.1 Jan 11, 2019
18 checks passed
@georgyberdyshev
Copy link
Contributor Author

@georgyberdyshev georgyberdyshev commented Jan 12, 2019

Thanks @benjamn !

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

Successfully merging this pull request may close these issues.

None yet

3 participants