Skip to content

Instantly share code, notes, and snippets.

Created June 8, 2012 18:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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:
# @proxy_port - the port that we are duplexing to (ex: 80)
Proxy.start(:host => "", :port => <%= @emproxy_port %>) do |conn|
conn.server :self, :host => '', :port => <%= @nginx_port %>
conn.server :proxy, :host => '<%= @proxy_ip %>', :port => <%= @proxy_port %>
conn.on_data do |data|
conn.on_response do |server, resp|
resp if server == :self
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment