All Projects → jeremy → rack-reproxy

jeremy / rack-reproxy

Licence: MIT license
Transparently proxy Rack responses from a backend URL. Great for private access to an internal service or to route authenticated requests through intermediate caching layers.

Programming Languages

ruby
36898 projects - #4 most used programming language

Labels

Projects that are alternatives of or similar to rack-reproxy

As
VCV Rack Modules
Stars: ✭ 104 (+420%)
Mutual labels:  rack
Rack csrf
Anti-CSRF Rack middleware
Stars: ✭ 169 (+745%)
Mutual labels:  rack
Plezi
Plezi - the Ruby framework for realtime web-apps, websockets and RESTful HTTP
Stars: ✭ 239 (+1095%)
Mutual labels:  rack
Capybara discoball
Spin up an external server just for Capybara
Stars: ✭ 116 (+480%)
Mutual labels:  rack
Sinatra
Classy web-development dressed in a DSL (official / canonical repo)
Stars: ✭ 11,497 (+57385%)
Mutual labels:  rack
Trashed
Tell StatsD about request time, GC, objects and more. Latest Rails 4 and Ruby 2.1 support, and ancient Rails 2 and Ruby 1.8 support.
Stars: ✭ 188 (+840%)
Mutual labels:  rack
Ferrocarril
🚆 Experiments to embed Ruby on Rails in Rust with mruby
Stars: ✭ 66 (+230%)
Mutual labels:  rack
Slide
MasahiroSaito's Slides Repository
Stars: ✭ 12 (-40%)
Mutual labels:  rack
Sham rack
run Rack applications in-process, without a server
Stars: ✭ 169 (+745%)
Mutual labels:  rack
Split
📈 The Rack Based A/B testing framework
Stars: ✭ 2,539 (+12595%)
Mutual labels:  rack
Crepe
The thin API stack.
Stars: ✭ 120 (+500%)
Mutual labels:  rack
Prax.cr
Rack proxy server for development (Crystal port)
Stars: ✭ 142 (+610%)
Mutual labels:  rack
Bugsnag Ruby
Bugsnag error monitoring & reporting software for rails, sinatra, rack and ruby
Stars: ✭ 211 (+955%)
Mutual labels:  rack
Rack Weixin
微信公众平台 开放消息接口 Rack Middleware
Stars: ✭ 105 (+425%)
Mutual labels:  rack
Rack Reducer
Declaratively filter data via URL params, in any Rack app, with any ORM.
Stars: ✭ 241 (+1105%)
Mutual labels:  rack
Cuba
Rum based microframework for web development.
Stars: ✭ 1,385 (+6825%)
Mutual labels:  rack
Thin
A very fast & simple Ruby web server
Stars: ✭ 2,170 (+10750%)
Mutual labels:  rack
tipi
Tipi - the All-in-one Web Server for Ruby Apps
Stars: ✭ 214 (+970%)
Mutual labels:  rack
rack-session-smart cookie
Slightly smarter session cookies for Rack 2 apps
Stars: ✭ 43 (+115%)
Mutual labels:  rack
Controller
Complete, fast and testable actions for Rack and Hanami
Stars: ✭ 221 (+1005%)
Mutual labels:  rack

Rack::Reproxy Build Status

Allow Rack responses to be proxied from a different URL. It's like Rack::Sendfile, but for any HTTP backend.

Rack apps can return a URI as a response body (or an X-Reproxy-Url header) and we pass it upstream to Nginx/Apache/Lighttpd to serve.

This is an approach pioneered by MogileFS using perlbal to reproxy file requests to an internal storage backend.

Proxing to an internal app: serving private files

Rack::Sendfile can efficiently serve files from the local filesystem. But that means you have to have your files NFS-mounted on all your app servers, and you have to know their physical paths.

Instead, you can expose your file server as a private HTTP service and reproxy requests to it. Get rid of fussy NFS mounts and just stream files back from your internal server.

Proxying to yourself

You can reproxy requests back to your own app, too. This is useful when you you'd like to HTTP-cache private, authenticated content. You can't put a public HTTP cache in front of your app, but you can put it in the middle!

Your app receives a request, authenticates, and proxies its own response via an internal HTTP cache that's backed by... your app.

Nginx

In config.ru

use Rack::Reproxy::Nginx, location: '/reproxy'

Nginx config

location /reproxy {
  internal;
  set $reproxy_url $upstream_http_x_reproxy_url;
  proxy_pass $reproxy_url;
}

Apache with mod_reproxy

In config.ru

use Rack::Reproxy::Apache

Apache config. Requires the mod_reproxy module.

<Location />
  AllowReproxy on
  PreserveHeaders Content-Type Content-Disposition ETag Last-Modified
</Location>

Lighttpd

In config.ru

use Rack::Reproxy::Lighttpd

Lighttpd config

proxy-core.allow-x-rewrite = "enable"

Rack

Wait, what? Yeah, you can reproxy without doing an HTTP roundtrip by immediately redispatching back to your own app. This becomes useful when you do something like reproxy through Rack::Cache or want to emulate your nginx/apache reproxies in dev/test with Rack only.

In config.ru

# To proxy to self
use Rack::Reproxy::Rack

# To proxy to a different Rack app
use Rack::Reproxy::Rack, app: SomeInternalApp.new
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].