Skip to content

Instantly share code, notes, and snippets.

@ehlertij
Created June 8, 2012 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ehlertij/2897400 to your computer and use it in GitHub Desktop.
Save ehlertij/2897400 to your computer and use it in GitHub Desktop.
em-proxy proxy.rb.erb
# 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