Skip to content

Instantly share code, notes, and snippets.

@lfborjas
Created September 10, 2011 03:54
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lfborjas/1207894 to your computer and use it in GitHub Desktop.
Save lfborjas/1207894 to your computer and use it in GitHub Desktop.
Simple proxy server for developing front-ends for APIs (using rack middleware)
require 'rack'
require 'rack/proxy' #gem install rack-proxy
class Proxy < Rack::Proxy
def rewrite_env(env)
env["HTTP_HOST"] = "my.host.com"
env["SERVER_PORT"] = "80"
env
end
end
#serve static assets, your frontend
use Rack::Static, :urls => {"/" => "index.html"}
use Rack::Static, :urls => ["/css", "/images", "/js"]
run Proxy.new
#thin --rackup proxy.ru start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment