https://github.com/movableink/socketproxy
Expose a local node http handler via a remote URL
https://github.com/movableink/socketproxy
Last synced: 2 months ago
JSON representation
Expose a local node http handler via a remote URL
- Host: GitHub
- URL: https://github.com/movableink/socketproxy
- Owner: movableink
- License: mit
- Created: 2018-03-19T05:19:14.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T17:08:37.000Z (over 2 years ago)
- Last Synced: 2025-03-05T07:43:56.912Z (3 months ago)
- Language: JavaScript
- Size: 416 KB
- Stars: 1
- Watchers: 33
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# SocketProxy
Expose a local node http server via a remote URL.
Motivation: you run a local http-based node app that you want to expose to the world, and you also have the ability to run a public node app elsewhere.
SocketProxy comes in two parts:
* The SocketProxy client connects to the SocketProxy server via websockets and receives a public subdomain URL.
* The SocketProxy server listens on an http/https port, maps the request subdomain to a SocketProxy client, and then proxies the http/https request to the SocketProxy client over websockets.## Usage
The server works out of the box, the client will need to be customized for your app. Starting the server:
```bash
bin/server --port=8080
```See `bin/server --help` for all options.
An example client can be found at `bin/example-client`.
```javascript
const SocketProxy = require('socketproxy');const app = express();
app.use(...)const proxy = new SocketProxy({
url: 'ws://socketproxy-server:8080',
app: app
});proxy.connect().then((p) => {
console.log("Connected", p.uri);
});
```Replace `socketproxy-server` above with the hostname of your SocketProxy server.
## Alternatives
`localtunnel` is a popular alternative for some similar use cases. Notable differences are that it is actually a full TCP tunnel while the SocketProxy client connects directly to an express/connect handler, so doesn't generate any extra connections on the client machine. SocketProxy was developed because `localtunnel` isn't able to encrypt TCP traffic, and requires the use of all of the server's ports. For high-throughput uses, `localtunnel` is likely quite a bit faster since it will use many TCP connections rather than a single multiplexed-via-json websockets connection.
## License
See LICENSE.txt