about summary refs log tree commit homepage
path: root/lib/yahns/proxy_pass.rb
DateCommit message (Collapse)
2016-04-27proxy_pass: drop resources immediately on errors
We don't want to wait on GC to reap sockets on errors, generational GC in Ruby is less aggressive about reaping long-lived objects such as long-lived HTTP connections.
2016-02-13proxy_pass: pass X-Forwarded-Proto through
This allows backend application servers to set "rack.url_scheme" as appropriate using Rack::Request#scheme. Plack/PSGI users can also take advantage of this using Plack::Middleware::ReverseProxy
2016-01-02copyright updates for 2016
Using the 'update-copyright' script from gnulib[1]: git ls-files | UPDATE_COPYRIGHT_HOLDER='all contributors' \ UPDATE_COPYRIGHT_USE_INTERVALS=2 \ xargs /path/to/gnulib/build-aux/update-copyright We're also switching to 'GPL-3.0+' as recommended by SPDX to be consistent with our gemspec and other metadata (as opposed to the longer but equivalent "GPLv3 or later"). [1] git://git.savannah.gnu.org/gnulib.git
2016-01-02enable frozen_string_literal for Ruby 2.3+
There are likely yet-to-be-discovered bugs in here. Also, keeping explicit #freeze calls for 2.2 users, since most users have not migrated to 2.3, yet.
2015-12-15nodoc internals
We do not expose any sort of API beyond what's in the config file manpage to our users. Do not mislead them into thinking we currently have a stable API (though I'm considering one). This avoids wasting disk space and installation time for users who do not have a: "gem: --no-ri --no-rdoc" line in their ~/.gemrc
2015-10-03proxy_pass: quiet down ECONNRESET and EPIPE, too
Clients may disconnect on us while we're writing the response here, so we should shut the backtrace up to avoid polluting logs.
2015-05-18proxy_pass: allow filtering or overriding response headers
We shouldn't blindly pass the "Server" tag through, since we may be proxying Apache instances and we don't want to misadvertise, either. IMHO, it is best to say nothing at all to save bandwidth and reduce the potential for attackers in case a vulnerability is discovered in yahns.
2015-05-12proxy_pass: no point in closing StringIO
It does not release memory immediately and GC can handle it reliably, so don't waste a constant lookup + cache entry on it. While we're at it, explain why we can't do a simpler respond_to? check instead.
2015-05-09proxy_pass: favor literal hash over arrays for error responses
Arrays are less verbose, but they have more bytecode overhead which actually matters at runtime.
2015-05-08proxy_pass: avoid unnecessary close method
No point in wasting space and reducing code clarity with this method to remove references to live objects.
2015-04-24proxy_pass: clear backtrace on ECONNREFUSED
Bad connections or dead upstreams cannot be solved looking at a backtrace, so avoid polluting logs with them and making other problems less visible.
2015-04-11proxy_pass: attempt to forward premature upstream responses
Upstreams may shut us down while we're writing a request body, attempt to forward any responses from the upstream back to the client which may explain the rejection reason for giant uploads.
2015-04-09proxy_pass: capture local variable earlier for rescue
This giant method needs to spew an error response in case uploads to the upstream fail, ensure the local variable is defined early.
2015-04-07proxy_pass: avoid needless regexp
A dumb string comparison will do here, so there's no point in paying the memory and CPU cost of a regexp match when we already extracted the suffix from a header key.
2015-04-07proxy_pass: possibly avoid breaking some middlewares
hijack seems incompatible with many middlewares, so return a wonky response tuplet just in case...
2015-04-07proxy_pass: send 1.0 requests to upstreams for 1.0 clients
We cannot pass trailers from upstreams to HTTP/1.0 clients without fully-buffering the response body AND trailers before forwarding the response header. Of course, one of the reasons yahns exists is to support lazy buffering, so fully-buffering up front is wasteful and hurts latency. So instead, degrade to 1.0 requests to upstreams for HTTP/1.0 clients, this should prevent upstreams from sending trailers in the first place. HTTP/1.0 clients on Rails apps may suffer, but there probably are not too many HTTP/1.0 clients out there.
2015-04-07proxy_pass: preliminary support for passing trailers
Rack apps may (through a round-about way) send HTTP trailers to HTTP/1.1 clients, and we need a way to forward those responses through without losing the trailers.
2015-04-03proxy_pass: test and fix larger uploads
We were incorrectly stashing the return value of detach_rbuf! into the inter-thread buffer buffer which is bound to the client.
2015-04-03proxy_pass: rewrite to be async, using rack.hijack
This allows our reverse proxy to avoid having an innefficient 1:1 relationship between threads and upstream connections, reducing memory usage when there are many upstream connections (possibly to multiple backend machines).
2015-03-14proxy_pass: officially become a part of yahns
This will rely on rack.hijack in the future to support asynchronous execution without tying up a thread when waiting for upstreams. For now, this allows simpler code with fewer checks and the use of monotonic time on newer versions of Ruby.