Tunnel HTTP connections via socket.io streams. Inspired by localtunnel.
- Clone this repo and cd into it
- Update the Docker file to add a password to the command line (see notes below)
- docker build -t socket-tunnel .
- docker run -d -p 80:3000 --restart=always --name st-server socket-tunnel
- Get a domain name (i.e. YOURDOMAIN.com)
- Point your domain name's root A record at your server's IP
- Point a wildcard (*) A record at your server's IP
Note : if you are hosting on a subdomain, you will need to start the server with the --subdomain
option.
For instance if you are using tunnel.example.com
the option will be --subdomain tunnel
and the tunnels created will be sudomains of tunnel.example.com
.
To do so, replace the following line in the Dockerfile
:
CMD [ "node", "bin/server" ]
by
CMD [ "node", "bin/server", "--subdomain", "tunnel" ]
Even if you are not using a subdomain, you will need to modify the Dockerfile to add the option --password
to protect your server instance :
CMD [ "node", "bin/server", "--password", "pony-excelsior-virtuoso"]
- Start your http server that you'd like to expose to the public web (in this example we'll assume it's listening on 127.0.0.1:8000)
- Clone this repo and cd into it
npm i
node bin/client --server http://YOURDOMAIN.com --subdomain YOURSUBDOMAIN --hostname 127.0.0.1 --port 8000 --pwd pony-excelsior-virtuoso
- Browse to http://YOURSUBDOMAIN.YOURDOMAIN.com to see your local service available on the public internet
Assuming a web server running on 127.0.0.1:8000
- Clone this repo into your project
npm i
- In your project file, require the socket-tunnel api and call connect():
const socketTunnel = require('./socket-tunnel/lib/api');
socketTunnel.connect('http://YOURDOMAIN.com', 'YOURSUBDOMAIN', '8000')
.then(console.log)
.catch(console.log);
- Browse to http://YOURSUBDOMAIN.YOURDOMAIN.com to see your local service available on the public internet
socketTunnel.connect(remoteServer, desiredSubdomain, localPort, localHostname)
returns a promise which resolves to the requested URL/subdomain.
Property | Default | Description |
---|---|---|
remoteServer | n/a | IP address or hostname of the socket-tunnel server |
desiredSubdomain | n/a | Subdomain to request for this client |
localPort | n/a | Local port to tunnel to |
localHostname | '127.0.0.1' | Local host to tunnel to |
Created by Eric Barch. Additional code provided by these generous contributors.
This project is licensed under the MIT License - see the LICENSE file for details