Introduction
"What if a single command could let users from anywhere in the world access your locally running web server?"
This is Part 13 of the "Open Source Project of the Day" series. Today we explore Tunnelto (GitHub).
When developing and testing web applications, we often need to expose local services to external access β whether for remote colleagues to test, integrating third-party webhooks, or demonstrating to clients. Traditional solutions are either complex to configure, perform poorly, or require payment. Tunnelto is built with Rust and Tokio async IO, providing a high-performance, easy-to-use local tunnel solution that lets you expose your local service to the internet with a single command.
What You'll Learn
- Tunnelto's core architecture and technical characteristics
- How to use Tunnelto to quickly expose local services
- Rust async IO in network tunneling applications
- Tunnelto vs. other local tunnel tools
- How to self-host a Tunnelto server
- Tunnelto's advanced features and configuration options
- Application cases in real development scenarios
Prerequisites
- Basic understanding of networking (TCP/IP, HTTP)
- Understanding of local development server concepts
- Familiarity with command-line tools
- Basic knowledge of Rust (optional, helps understand implementation principles)
Project Background
Project Introduction
Tunnelto is a high-performance local tunnel tool written in Rust that allows you to expose a locally running web server to the internet with a simple command, obtaining a publicly accessible URL. Built entirely on async IO (Tokio), it delivers excellent performance while supporting custom subdomains and self-hosted deployment.
Core problems the project solves:
- Local development services can't be accessed externally, hindering collaboration and testing
- Traditional local tunnel tools are complex to configure with poor performance
- Cannot use localhost when integrating third-party services (like OAuth callbacks, Webhooks)
- Commercial solutions are expensive or restricted
- Need self-hosted solutions to protect privacy and data security
Target user groups:
- Web developers and full-stack engineers
- Developers who need quick demonstrations and testing
- Developers integrating with third-party APIs
- Developers with performance and privacy requirements
- Teams needing self-hosted local tunnel services
Author/Team Introduction
Author: Alex Grinman (@agrinman)
- Background: Developer focused on systems programming and network technology
- Project creation date: 2020
- Philosophy: Build a high-performance, easy-to-use, self-hostable local tunnel tool
- Tech stack: Rust, Tokio, async IO
Project Stats
- β GitHub Stars: 5.7k+ (continuously growing)
- π΄ Forks: 432+
- π¦ Version: 0.1.18 (latest version, released May 16, 2021)
- π License: MIT
- π Website: tunnelto.dev
- π¬ Community: Active GitHub Issues
Project development history:
- 2020: Project created, initial version released
- 2020-2021: Continuous optimization, new features added
- May 2021: Released version 0.1.18, stable feature set
- Ongoing maintenance: Project remains active with continuous community contributions
Main Features
Core Purpose
Tunnelto's core purpose is to expose locally running web servers to the internet via public URLs, with main features including:
- Quickly expose local services: A single command maps a local port to a public URL
- Custom subdomains: Supports specifying custom subdomains for easy remembering and use
- API authentication: Supports API key authentication to protect tunnel security
- Self-hosting support: Can deploy your own Tunnelto server
- High performance: Based on Rust and Tokio async IO for excellent performance
- Local dashboard: Provides a local monitoring and debugging interface
Use Cases
-
Web development testing
- Let remote team members access the local development environment
- Test responsive design on mobile devices
- Demonstrate to clients or product managers
-
Third-party service integration
- OAuth callback URL configuration (GitHub, Google, etc.)
- Webhook reception (Stripe, GitHub Actions, etc.)
- Third-party API testing and debugging
-
API development and debugging
- Let frontend developers access local API services
- Test mobile app integration with backend APIs
- Debug cross-origin issues
-
Temporary demos and sharing
- Quickly share local projects with others
- Temporary demos and prototype presentations
- Showcase features without deployment
-
CI/CD integration
- Expose test services in CI environments
- Service access in automated testing
- Setting up temporary test environments
Quick Start
Installation
macOS (Homebrew):
brew install agrinman/tap/tunnelto
Cargo (Rust users):
cargo install tunnelto
Other platforms:
Download the binary for your platform from GitHub Releases.
Simplest Usage Example
# Expose local port 8000 service
tunnelto --port 8000
After running, you'll see output like this:
π Starting tunnelto...
π Public URL: https://abc123.tunnelto.dev
π Dashboard: http://localhost:4040
Now anyone can access your local localhost:8000 service through https://abc123.tunnelto.dev.
Custom Subdomain
# Use a custom subdomain
tunnelto --port 8000 --subdomain myapp
This will generate the URL https://myapp.tunnelto.dev.
Specify Local Host and Protocol
# Specify local host and protocol
tunnelto --port 3000 --host 127.0.0.1 --scheme https
Core Features
-
Ultra-simple usage
- A single command to use, no complex configuration
- Automatically generates public URL, works out of the box
- Supports multiple installation methods
-
High-performance async IO
- Based on Rust and Tokio for excellent performance
- Async processing, supports high-concurrency connections
- Low latency, fast response
-
Custom subdomains
- Supports specifying custom subdomains
- Easy to remember and use
- Suitable for production environment use
-
API authentication
- Supports API key authentication
- Protects tunnel security
- Prevents unauthorized access
-
Local dashboard
- Provides local monitoring interface
- View request logs and statistics
- Convenient for debugging and monitoring
-
Self-hosting support
- Can deploy your own server
- Complete control over data and privacy
- Supports distributed deployment (using Fly.io)
-
Multi-protocol support
- Supports HTTP and HTTPS
- Automatically handles protocol conversion
- Flexible configuration
-
Cross-platform
- Supports macOS, Linux, Windows
- Multiple installation methods available
- Unified command-line interface
Project Advantages
| Comparison | Tunnelto | ngrok | localtunnel |
|---|---|---|---|
| Performance | βββββ Rust async IO | ββββ Go implementation | βββ Node.js |
| Ease of use | βββββ Single command | ββββ Simple | ββββ Simple |
| Self-hosting | β Full support | β Requires payment | β Supported but limited |
| Custom domains | β Free support | β Requires payment | β Not supported |
| Open source | β MIT | β Partially open source | β MIT |
| Resource usage | βββββ Ultra-low | ββββ Low | βββ Moderate |
| Community activity | ββββ Active | βββββ Very active | βββ Average |
Why choose Tunnelto?
- Excellent performance: Rust and Tokio combination brings exceptional performance, suitable for high-concurrency scenarios
- Fully open source: MIT license, completely open code, free to use and modify
- Self-hosting friendly: Provides a complete self-hosting solution to protect privacy and data security
- Simple and easy to use: A single command to use, low learning curve
- Low resource usage: Small Rust-compiled binary, minimal runtime resource consumption
- Actively maintained: Project continuously updated, active community
Detailed Project Analysis
Architecture Design
Tunnelto uses a client-server architecture with three core components:
- Tunnelto Client: Runs locally on the user's machine, responsible for establishing the tunnel
- Tunnelto Server: Runs in the cloud, responsible for forwarding traffic
- Control WebSocket: Control channel between client and server
Core Modules
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β Browser ββββββββββΆβ Tunnelto ββββββββββΆβ Local β
β (Internet) β β Server β β Server β
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β²
β Control WebSocket
β
βββββββββββββββ
β Client β
β (Local) β
βββββββββββββββ
Workflow:
- Establish control connection: Client connects to server via WebSocket, establishing a control channel
- Register tunnel: Client registers the tunnel with the server, obtaining a public URL
- Traffic forwarding: When a request arrives at the public URL, the server notifies the client via the control channel
- Establish data connection: Client establishes a connection to the local service
- Bidirectional forwarding: Server and client bidirectionally forward HTTP requests and responses
Key Implementation
Async IO Architecture
Tunnelto is built entirely on Tokio async runtime, fully leveraging Rust's async capabilities:
// Pseudo-code example: core async processing logic
async fn handle_tunnel_connection(stream: TcpStream) -> Result<()> {
// Async TCP connection handling
let (reader, writer) = stream.split();
// Async read and write
tokio::spawn(async move {
// Handle data forwarding
});
Ok(())
}
Advantages:
- High concurrency: Single thread can handle a large number of concurrent connections
- Low latency: Async IO avoids thread context switching overhead
- Resource efficient: Lower resource usage compared to traditional multi-thread models
Tunnel Management
Tunnelto uses subdomain routing to manage multiple tunnels:
- Each tunnel is assigned a unique subdomain
- Server routes to the corresponding tunnel based on the Host header
- Supports custom subdomains for easy remembering and use
Self-Hosting Implementation
Tunnelto provides a complete self-hosting solution:
Single instance deployment:
- Compile musl target (static linking)
- Deploy using Docker
- Configure environment variables
Distributed deployment (official approach):
- Use Fly.io's Private Networking
- Implement Gossip protocol for service discovery
- Supports multi-instance load balancing
Key configuration (tunnelto_server/src/config.rs):
-
ALLOWED_HOSTS: Allowed hostnames -
CTRL_HOST: Control server address -
CTRL_PORT: Control server port -
CTRL_TLS_OFF: Whether to disable TLS (for local testing)
Security Mechanisms
-
API key authentication
- Supports setting API keys
- Prevents unauthorized access
- Protects tunnel security
-
TLS encryption
- Uses HTTPS by default
- End-to-end encryption
- Protects data transmission security
-
Access control
- Supports configuring allowed hostnames
- Prevents domain hijacking
- Enhances security
Performance Optimization
-
Zero-copy technique
- Rust's ownership system avoids unnecessary memory copies
- Improves data transfer efficiency
-
Connection pool management
- Reuses TCP connections
- Reduces connection establishment overhead
-
Async batch processing
- Batch processes requests
- Improves throughput
Extension Mechanisms
Although Tunnelto itself has relatively simple functionality, it provides good extensibility:
-
Custom server
- Can modify server code
- Add custom features
- Integrate into existing systems
-
Environment variable configuration
- Flexible configuration through environment variables
- Supports different deployment scenarios
- Easy to integrate into CI/CD
-
API interface
- Control WebSocket protocol is open
- Can develop custom clients
- Integrate into other tools
Project Resources
Official Resources
- π GitHub: https://github.com/agrinman/tunnelto
- π Documentation: GitHub README includes complete usage guide
- π Website: https://tunnelto.dev
Who Should Use This
Tunnelto is especially suitable for the following developers:
-
Web developers
- Need to quickly expose local services for testing
- Need to integrate third-party services (OAuth, Webhooks)
- Need to demonstrate and share local projects
-
Full-stack engineers
- Need frontend to access local APIs
- Need to test mobile app integration with backend
- Need to debug cross-origin issues
-
DevOps engineers
- Need to self-host local tunnel services
- Need to integrate into CI/CD workflows
- Have performance and security requirements
-
Rust developers
- Want to learn Rust async IO practices
- Want to understand network programming best practices
- Want to contribute to open source projects
-
Privacy-conscious developers
- Don't want to use third-party commercial services
- Need complete control over data
- Need self-hosted solutions
Welcome to visit my personal homepage for more useful knowledge and interesting products
Top comments (0)