-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unix socket support #104
Comments
I had the same problem. I was expecting this to work since it works seamlessly in node core. Anyway, @jimisaacs solution is working right now. |
Here is a suggestion for a possible change: var proxyServer = httpProxy.createServer({
router: {
'app1.local': [8080, localhost]
, 'app2.local': [null, 'localhost'] // null defaults to 80
, 'app3.local': [8181] // port as number treated normally
, 'app4.local': ['/tmp/myapp.sock'] // port as a string is treated as unix socket
}
}); Whether this is actually proxying other node servers or not, this setup still simply looks like arguments for other servers' listen methods. |
@jimisaacs +1, just ports too, defaulting the host would be nice & a very common use-case for people just wanting cheap vhost-like behaviour httpProxy.createServer({
router: {
'foo.bar': 3001
, 'bar.baz': 3002
}
}) etc |
I gave this solution a try and started a pull request thread |
By the way I +1 @visionmedia proposal too. |
@Floby How does your pull request support UNIX sockets? |
errr, I inverted host and port. I updated the pull request. httpProxy.createServer({
router: {
'unix-socket.com': ['/tmp/app.sock'],
'usual.com': [8094, '127.0.0.1']
}
}) String targets still work. I haven't found a simple way to add the proper testing though since it seems that you can't use UNIX sockets with Mickeal's |
+1 Floby's pull request. |
Sorry, I think you can tell I don't actually comment very much on github. |
added testing. Some testing helpers were acting funny but it works now. |
@Floby I want to accept your pull request, but there is a big set of changes coming down the pipeline for I will leave this open as a reminder to do so. |
no problem. The magic colon is working for me for now. |
Error while using magic colon for
I think there is new checking for host and port exists
|
Any update on this? |
I would also like this. |
@brianloveswords I would like you to implement it ;) |
@indexzero I'll see if I can start throwing together a patch today! |
@indexzero @brianloveswords Hey, guys. I don't want to be a party-crasher but this neat bug still isn't fixed yet.If you don't want to or can't fix it could you please point me to the lines of codes, that probably cause the problem? I'd then try to fix it myself and make a pull request. Thanks! |
Fixed it myself. Pull Request: #254 |
Fixed in #294 |
You can't imagine, how much I love you. |
So I wanted to use node-http-proxy to serve content from multiple apps running locally on unix sockets.
I found out quick that this was not going to work:
I spent the next 5 hours or so trying to figure out why.
It turns out the problem was in this method:
That method is always looking for a host and a port, because it does a split on the string. It could easily be modified to use a unix socket path, which is the first argument for the net.Server.listen method, the same as a port. The core lib simply checks if this value is a number or a string.
So anyway, rather than modifying the code because I didn't want to monkey around in there just yet. The simple solution after 5 hours of trying to make this reverse proxy unix sockets was this:
That my friends, is one magical colon.
Thanks again for this great and extremely useful module. Let me know what you think about all this, I can try to contribute.
Jim
The text was updated successfully, but these errors were encountered: