1.1.1 • Published 3 years ago

husp v1.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

TCP to Unix Socket HTTP Proxy

License

This software is released under the MIT License.

What?

This simple command line application will start a basic web server, that will listen for incoming HTTP requests. It will interpret the first part of the path of a request as a unix socket name (in a configured base path). Finally, it will verify the unix socket, and forward the request to it if possible. If there is an HTTP server listening on the unix socket, you should be able to browse it using a regular browser.

Why

When running node applications, especially on a local development machine, it is not always the best approach to use TCP to expose your web services. This exposes them to the network stack, and also requires quite a bit of extra configuration.

On the other hand, unix sockets are pretty standard, safe, faster and easy to configure. You can load-balance them just fine with NGinX or Haproxy. Less trouble, more fun ;-)

But: accessing an http server exposed via a unix socket from within your browser, postman or other tooling... that's something else. Hence this tool. It will allow you to do just that. It creates a bridge/proxy that maps the unix sockets a single TCP endpoint so you can browse all you want.

Features

  1. Translate the path into a socket location:
    GET /some.socket/api/version
    --> GET unix@/basepath/some.socket:/api/version
  2. Multiple sockets via one proxy given the same path
  3. Logging of requests and responses
  4. Rewriting of paths and relative location headers in the response (for 301/302 redirects), where Location: /something would be rewritten as Location: /some.socket/something.

How to:

npm -g install husp
husp [<targetPath>]
  • where targetPath is a directory that contains unix socket files.

Then browse to localhost:3000/socketFileName/something. The proxy will forward your HTTP request to the unix socket of your choice, provided that a socket called socketFIleName exists within the targetPath and that a server is listening on it.

Dependencies

The software has a dependency on - but does not include :

  • tslog (MIT) logging library
  • expressjs (MIT) web framework

Disclaimer

This tool was created in a couple of spare hours in order to enable easy testing for another project. It is not guaranteed to work in your case. See the enclosed MIT license for the full disclaimer.

Release notes

1.0.1 Documentation update and npm keywords added 1.0.0 First public release

1.1.1

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago