Created
June 8, 2012 18:23
-
-
Save ehlertij/2897400 to your computer and use it in GitHub Desktop.
em-proxy proxy.rb.erb
This file contains 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
# proxy.rb.erb | |
require 'em-proxy' | |
# @emproxy_port - the port we want this process receiving traffic on (ex: 8080) | |
# @nginx_port - the port that normally processes traffic that we are now duplexing (ex: 81) | |
# @proxy_ip - the IP address we are duplexing to (ex: 10.10.10.10) | |
# @proxy_port - the port that we are duplexing to (ex: 80) | |
Proxy.start(:host => "0.0.0.0", :port => <%= @emproxy_port %>) do |conn| | |
conn.server :self, :host => '127.0.0.1', :port => <%= @nginx_port %> | |
conn.server :proxy, :host => '<%= @proxy_ip %>', :port => <%= @proxy_port %> | |
conn.on_data do |data| | |
data | |
end | |
conn.on_response do |server, resp| | |
resp if server == :self | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment