Comments (4)
Hmm, that's a great question. Assuming your box has multiple IP's assigned to it... I'm not sure if EventMachine has any API's for picking a specific interface to initiate an outgoing connection.
@tmm1: any thought on this?
Equivalent for curl: http://stackoverflow.com/questions/2425651/select-outgoing-ip-for-curl-request
from em-proxy.
Use EM.bind_connect
from em-proxy.
Ah, figures.. Never used that API before. Thanks!
@barbolo, so the answer is: yes it is possible, but it would require some patching to support this use case :-)
from em-proxy.
Thanks @tmm1 and @igrigorik!
I tryed patching the em-proxy gem and believe I got it working. One new problem is that EM.bind_connect (as well as EM.connect) seems not to work correctly with IPv6. The IP addresses attached to my machine are all IPv6.
I replaced the following line of lib/em-proxy/connection.rb:
srv = EventMachine::connect(opts[:host], opts[:port], EventMachine::ProxyServer::Backend, @debug) do |c|
with:
ipv6 = Socket.ip_address_list.sample # choose a random ipv6 attached to the machine
srv = EventMachine::bind_connect(ipv6, nil, opts[:host], opts[:port], EventMachine::ProxyServer::Backend, @debug) do |c|
from em-proxy.
Related Issues (20)
- NoMethodError: undefined method `on_headers_complete=' for #<Http::NativeParser HOT 5
- Balancing sample doesn't seem to give a new server for every request HOT 2
- Early binding for proxy port HOT 4
- Spec: duplex TCP traffic to two backends google & yahoo is hanging HOT 2
- Can't proxy to pow's domains HOT 3
- Add support for proxying unix domain sockets (JRuby) HOT 6
- Backend selection based on sub-domain HOT 1
- No eventmachine 1.0 support? HOT 4
- On SIGINT foreman throws an error HOT 1
- Skip proxying and just send a response HOT 1
- Select backend on request data HOT 2
- Error HOT 1
- http_proxy.rb -- invalid request URI HOT 3
- http_proxy.rb -- breaking proxy request by adding/duplicating data HOT 6
- http_proxy.rb -- breaking proxy request by adding/duplicating data #52 HOT 2
- Can not re-open issue #52
- Missing licence in rubygems.org
- Missing LICENSE file in rubygem HOT 1
- Syntax error in examples/http_proxy.rb HOT 1
- 2 network HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from em-proxy.