Last active
December 15, 2015 15:38
-
-
Save alvinsj/5283163 to your computer and use it in GitHub Desktop.
Setup Proxy Server in Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'daemons' | |
Daemons.run('./proxy.rb') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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