Skip to content

Instantly share code, notes, and snippets.

@alvinsj
Last active December 15, 2015 15:38
Show Gist options
  • Save alvinsj/5283163 to your computer and use it in GitHub Desktop.
Save alvinsj/5283163 to your computer and use it in GitHub Desktop.
Setup Proxy Server in Ruby
require 'daemons'
Daemons.run('./proxy.rb')
require 'em-proxy'
Proxy.start(host: "0.0.0.0", port: 8080, debug: true) do |conn|
conn.server :production, :host => 'dev.some_host.com', :port => 80
conn.on_data do |data|
data
end
conn.on_response do |server, resp|
resp if server == :production
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment