-
Notifications
You must be signed in to change notification settings - Fork 61
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
Add option to pass through compression #27
Conversation
@kylewlacy Thanks for your submission! I'll try to take a look at this before the week ends! |
@kylewlacy Apologies for getting to this so late! I'd like to propose changing the option to I was looking more into the
With this we can set reverse_proxy "http://localhost:8080",
reset_accept_encoding: false,
headers: { 'Accept-Encoding' => 'gzip' } whereas in this instance, we are aware that reverse_proxy "http://localhost:8080",
reset_accept_encoding: true,
headers: { 'Accept-Encoding' => 'gzip' } About the Varnish stuff, I would need test it with this new version. I don't mind cutting a major version just in case there's breaking changes. Super interested to hear your thoughts on this and thanks again for your time! 👍 |
@axsuul That sounds reasonable to me! I agree that |
The default is to now to not clear the `Accept-Encoding` header (this can be changed back to the older behavior by passing `reset_accept_encoding: true`)
@axsuul Okay, sorry for the delay! The last two weeks have been kind of hectic for me. I finally had some free time so I updated this PR with the changes you suggested. Feel free to look it over again and I can make any other changes if needed |
copied from axsuul#27
copied from axsuul#27
any updates on this PR @axsuul? |
Sorry for the delay, released as |
We are using
rails-reverse-proxy
in front of a small server that serves static compressed assets. Eventually we noticed that assets were always being served uncompressed, and after some digging, I came across the spot where theAccept-Encoding
header is stripped from proxied requests.This PR adds a new
:compression
option to control howrails-reverse-proxy
handles theAccept-Encoding
header.:disabled
(default) disables all compression, just likerails-reverse-proxy
does today.:passthrough
forwards theAccept-Encoding
header, which will then allow the proxied server to return compressed responses (but it does not compress uncompressed proxy responses). A future PR could add another option to allow uncompressed responses to be compressed byrails-reverse-proxy
, but I decided not to add it to this PR since we didn't need it for our server.Also, I don't have any experience working with Varnish, so I can't say for certain if
compression: :passthrough
would still cause Varnish to error out (like the previous comment in the code suggests), so hopefully someone else can chime in on that.I will say I found some really weird behavior with Rack and the
Accept-Encoding
header. Previously, proxied request headers were set withNet::HTTPRequest#initialize_http_header
, but for some reason, it looked like Rack would ignore theAccept-Encoding
header? I'm not sure if that was because the version of Rack we were using, our version of Rails, or some other dependency... but I found that removing#initialize_http_header
and usingHTTPRequest::new
to set the header instead seemed to fix it. I wonder if the issue with Varnish was caused by this same issue as well...