GithubHelp home page GithubHelp logo

danowitz / lite-http-tunnel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from web-tunnel/lite-http-tunnel

0.0 0.0 0.0 34 KB

HTTP tunnel tool to expose local HTTP server to internet

License: GNU General Public License v3.0

JavaScript 100.00%

lite-http-tunnel's Introduction

Lite HTTP Tunnel

A HTTP Tunnel tool to help you expose local HTTP server behind a NAT or firewall to the internet. Inspired by Ngrok.

http tunnel

How it work

The tunnel is based on WebSocket. We have a WebSocket connection between the client and server to stream HTTP request from public server to your local server.

Usage

Deploy at public server

Firstly please deploy this project to your own web host with public internet access. The project is just a Node.js web server based on Express.js. So just just deploy as what you do for deploying Node.js web server.

It is recommended to deploy into Heroku with Deploy To Heroku button below:

Deploy To Heroku

With Heroku, you can get a free HTTPS web server with a fixed public domain.

Get JWT Token

In first deployment, you need to provide JWT_GENERATOR_USERNAME and JWT_GENERATOR_PASSWORD environment variables, then you can access https://your_web_host_domain/tunnel_jwt_generator?username=your_generator_username&password=your_generator_password to get JWT Token. After you get JWT Token, you can remove JWT_GENERATOR_USERNAME and JWT_GENERATOR_PASSWORD environment variables to remove /tunnel_jwt_generator access.

You can also generate JWT Token in your local by following code here.

Setup Client

Please install lite-http-tunnel client in your local computer where it can access your local HTTP server.

$ npm i -g lite-http-tunnel
$ lite-http-tunnel -h

Config remote public server address:

$ lite-http-tunnel config server https://your_web_host_domain

Config jwt token that you got from server:

$ lite-http-tunnel config jwt your_jwt_token

Start client

$ lite-http-tunnel start your_local_server_port

Please replace your_local_server_port with your local HTTP server port, eg: 3000.

After that you can access your local HTTP server by access your_public_server_domain.

Multiple Clients

The server steams HTTP request to WebSocket connection which has same host value in request headers.

So if you have multiple domains for the proxy server, you can have multiple clients.

For example, you have https://app1.test.com and https://app2.test.com for this proxy server.

In client 1:

$ lite-http-tunnel config server https://app1.test.com -p app1
$ lite-http-tunnel start your_local_server_port -p app1

In client 2:

$ lite-http-tunnel config server https://app2.test.com -p app2
$ lite-http-tunnel start your_local_server_port -p app2

Related

A introduce article: Building a HTTP Tunnel with WebSocket and Node.JS

TODO

  • Add tests
  • Support multiple clients based on request path prefix
  • Support to stream WebSocket request

lite-http-tunnel's People

Contributors

embbnux avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.