Transparently proxy to local ports or sockets with advanced routing.
Reverse proxy with advanced routing capabilities
urlglob for route matching
NOTE This project is still early days. Use it on personal servers, side projects and other applications that aren't super critical. Please file bugs to help me track down issues!
$ npm install hyperproxy
Hyperproxy uses Server Name Indication to choose different certificates based on hostname. While SNI has wide support at this point, not all platforms support it, notably Windows XP. Microsoft is ending support for Windows XP, on 2014-04-08 so it is expected that the userbase with SNI capability will grow as the last holdouts on XP upgrade their systems.
There are number of things that can go wrong when trying to proxy a request: it could not match any routes, the socket could be missing or dead, the remote host could be down or something else completely unexpected.
When this happens, the default method of handling it will be to return a
HTTP 502: Bad Gateway to the requesting client. However, if you attach an event handler to any one of the events below, the default behavior will be bypassed (though you will still be able to invoke it from the event handler).
All event handlers other than
proxyError get four arguments:
(err, req, res, defaultHandler).
proxyError only receives the error.
defaultHandler is a reference to the default error handler. For example, if you wanted to log all unknown errors and passthrough to the default handler, you could do the following:
Gets emitted on any error, in addition to the more specific events below. This can be useful for logging.
A route couldn't be found
Couldn't find the socket file associated with the route
Couldn't find the host associated with the route
Catch-all for any other problems that occur when trying to attach an endpoint to a request.
These may be implemented as plugins later on.
HTTPSonly, no websocket support yet.
Copyright (c) 2013 Brian J. BrennanPermission is hereby granted, free of charge, to any person obtaining acopy of this software and associated documentation files (the"Software"), to deal in the Software without restriction, includingwithout limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and topermit persons to whom the Software is furnished to do so, subject tothe following conditions:The above copyright notice and this permission notice shall be includedin all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE ANDNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BELIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTIONOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTIONWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.