Skip to content

Instantly share code, notes, and snippets.

@MichalPekala
Created September 27, 2012 12:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichalPekala/3793722 to your computer and use it in GitHub Desktop.
Save MichalPekala/3793722 to your computer and use it in GitHub Desktop.
Rack Proxy with HTTP Basic Authentication
require 'rubygems'
require 'rack/streaming_proxy'
use Rack::Auth::Basic, "Restricted Area" do |username, password|
[username, password] == ['user', 'password']
end
use Rack::StreamingProxy do |request|
if request.path.start_with?("/proxy")
"http://other.host#{request.path}"
end
end
run proc{|env| [200, {"Content-Type" => "text/plain"}, ["Running..."]] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment