TunnelForge is a lightweight, open-source, self-hosted alternative to ngrok that provides tunneling services for exposing local applications to the internet. It supports HTTP, WebSocket, and any other TCP-based protocols, allowing seamless integration with modern applications.
Click the image above to watch the TunnelForge demo and learn how it works in action!
git clone https://github.com/elshadaghazade/tunnelforge.git
cd tunnelforge
npm install
npm run build
npm run server:dev
The server will generate a static subdomain (sub1)./etc/hosts
file:127.0.0.1 sub1.myproxy.com
npm run client:dev -- -h myproxy.com -p [SERVER_PORT_FROM_ENV] -q [LOCAL_APP_PORT] -r [LOCAL_APP_HOST]
http://sub1.myproxy.com:[INCOMING_PORT_FROM_ENV]
CLIENT_SERVER_PORT
and INCOMING_SERVER_PORT
in your cloud environment (e.g., AWS EC2).A
record for *.yourdomain.com
pointing to your server's IP.npm run server:prod
pm2 start ecosystem.config.js
npm run build
npm run client:prod -- -h yourdomain.com -p [SERVER_PORT_FROM_ENV] -q [LOCAL_APP_PORT] -r [LOCAL_APP_HOST]
Your public address is http://[UNIQUE_SUBDOMAIN].yourdomain.com:[INCOMING_PORT_FROM_ENV]
Set these variables in your .env.development
or .env.production
file:
NODE_ENV=production
CLIENT_SERVER_PORT=4000
INCOMING_SERVER_PORT=4001
SERVER_CLIENT_HOST=0.0.0.0
SERVER_INCOMING_HOST=0.0.0.0
RECONNECT_INTERVAL=1000
PROXY_SERVER_MAIN_HOST=globalmedbooking.com
CLIENT_PARAM_SERVER_HOST=127.0.0.1
CLIENT_PARAM_SERVER_PORT=4000
CLIENT_PARAM_LOCAL_APP_HOST=127.0.0.1
CLIENT_PARAM_LOCAL_APP_PORT=3010
You can easily run both the TunnelForge server and client using Docker. This approach simplifies deployment, ensuring a consistent environment for running the application
Prepare the .env
File
Create an .env file in the root directory with the following contents, adjusting the values to match your desired configuration:
NODE_ENV=production
CLIENT_SERVER_PORT=4000
INCOMING_SERVER_PORT=4001
SERVER_CLIENT_HOST=0.0.0.0
SERVER_INCOMING_HOST=0.0.0.0
RECONNECT_INTERVAL=1000
PROXY_SERVER_MAIN_HOST=yourcustomdomain.com
CLIENT_PARAM_SERVER_HOST=127.0.0.1
CLIENT_PARAM_SERVER_PORT=4000
CLIENT_PARAM_LOCAL_APP_HOST=127.0.0.1
CLIENT_PARAM_LOCAL_APP_PORT=3010
CLIENT_SERVER_PORT
and INCOMING_SERVER_PORT
: Ports exposed by the TunnelForge server.PROXY_SERVER_MAIN_HOST
: Your main domain to handle subdomains.CLIENT_PARAM_SERVER_HOST
and CLIENT_PARAM_SERVER_PORT
: Host and port of the TunnelForge server.CLIENT_PARAM_LOCAL_APP_HOST
and CLIENT_PARAM_LOCAL_APP_PORT
: Host and port of the local application to expose.Build and Run with Docker Compose
The provided docker-compose.yml
file is configured to build and run both the server and client. To start everything, simply run:
docker compose up -d
Server and Client Communication
CLIENT_SERVER_PORT
and INCOMING_SERVER_PORT
.PROXY_SERVER_MAIN_HOST
and generated subdomain.Accessing Your Public URL
After starting the services, the client will log the public URL for accessing your local application. This will be in the format:
http://[generated-subdomain].yourcustomdomain.com:[INCOMING_SERVER_PORT]
Explore the Docker Images
You can find the Docker images for TunnelForge on Docker Hub:
We welcome contributions! See our Contributing Guidelines for details.
TunnelForge is licensed under the MIT License.
Visit the official website of TunnelForge for more details: tunnelforge.org.
The full API and usage documentation is hosted on GitHub Pages.
If you'd like to view it locally or use it in a different hosting platform, the documentation is generated using TypeDoc and is located in the /docs folder.
Happy tunneling with TunnelForge!