| Crates.io | http-tunnel-common |
| lib.rs | http-tunnel-common |
| version | 0.3.0 |
| created_at | 2025-10-26 06:29:50.094922+00 |
| updated_at | 2025-10-26 21:04:49.60085+00 |
| description | Common utilities and types for http-tunnel |
| homepage | https://github.com/tyrchen/http-tunnel |
| repository | https://github.com/tyrchen/http-tunnel |
| max_upload_size | |
| id | 1900998 |
| size | 86,757 |
π English | δΈζζζ‘£
A serverless HTTP tunnel built with Rust and AWS Lambda, providing secure access to local development servers through public URLs - similar to ngrok, but fully serverless and self-hosted.
HTTP Tunnel allows you to expose local services (like localhost:3000) to the internet through a public URL. Perfect for:
Architecture: Fully serverless (AWS Lambda + API Gateway + DynamoDB) for cost-effective, auto-scaling infrastructure with zero operational overhead.
# Clone the repository
git clone https://github.com/tyrchen/http-tunnel.git
cd http-tunnel
# Build the forwarder agent
cargo build --release --bin ttf
# The binary will be at target/release/ttf
cargo install --git https://github.com/tyrchen/http-tunnel --bin ttf
# Deploy AWS infrastructure (Lambda, API Gateway, DynamoDB)
make deploy-infra
# Note the WebSocket endpoint from the output
# Forward local service to the internet (uses default endpoint and port 3000)
ttf
# Or specify custom endpoint and port
ttf --endpoint wss://YOUR_WEBSOCKET_ENDPOINT --local-port 8080
# You'll receive a public URL like: https://abc123.execute-api.us-west-2.amazonaws.com
Now any HTTP request to your public URL will be forwarded to your local service.
Default Configuration:
wss://ws.example.com/dev3000127.0.0.1Internet β API Gateway HTTP β Lambda β WebSocket β Local Agent β localhost:3000
β
DynamoDB (state)
Components:
ttf): Rust CLI agent running on your machineFor detailed architecture, see specs/0001-idea.md.
# Forward localhost:3000 to the internet (uses default endpoint)
ttf
# Or specify custom endpoint
ttf --endpoint wss://YOUR_ENDPOINT
# Forward a different local port
ttf --port 8080
# Or use short form
ttf -p 8080
# Use your own domain (requires custom domain setup)
ttf --endpoint wss://ws.yourdomain.com
# Override default endpoint via environment variable
export TUNNEL_ENDPOINT=wss://YOUR_CUSTOM_ENDPOINT
# Set authentication token
export TUNNEL_TOKEN=your_jwt_token
# Run with environment configuration
ttf
http-tunnel/
βββ apps/
β βββ forwarder/ # Local agent CLI (ttf binary)
β βββ handler/ # AWS Lambda function
βββ crates/
β βββ common/ # Shared library (protocol, models, utilities)
βββ infra/ # Pulumi infrastructure as code
β βββ src/ # TypeScript infrastructure modules
β βββ scripts/ # Deployment helper scripts
β βββ README.md # Infrastructure documentation
βββ testapp/ # Example TodoMVC API server for testing
β βββ main.py # FastAPI application
β βββ pyproject.toml # Python dependencies
βββ specs/ # Architecture and implementation specs
βββ 0001-idea.md # Architecture design
βββ 0002-common.md # Common library spec
βββ 0003-forwarder.md # Forwarder agent spec
βββ 0004-lambda.md # Lambda functions spec
βββ 0005-iac.md # Infrastructure spec
βββ 0006-implementation-plan.md
# Build all components
cargo build
# Build forwarder agent only
cargo build --bin ttf
# Build Lambda handler (requires cargo-lambda)
cargo lambda build --release --arm64 --bin handler
# Run tests
cargo test
# Run linter
cargo clippy
A sample TodoMVC API server is included in testapp/ for testing the HTTP tunnel:
# Run the test app on port 3000
make run-testapp
# The API will be available at http://localhost:3000
# Interactive docs at http://localhost:3000/docs
Test App Features:
Example Usage:
# In terminal 1: Start the test app
make run-testapp
# In terminal 2: Start the tunnel forwarder (uses default endpoint and port 3000)
ttf
# In terminal 3: Access your local app via the public tunnel URL
curl https://YOUR_TUNNEL_URL/todos
# Preview infrastructure changes
make preview-infra
# Deploy infrastructure
make deploy-infra
# Destroy infrastructure
make destroy-infra
To use your own domain instead of API Gateway URLs:
infra/Pulumi.dev.yamlSee infra/README.md for detailed instructions.
ttf CLI connects to AWS API Gateway WebSocket endpointttf --help
Options:
-e, --endpoint <URL> WebSocket endpoint URL [default: wss://ws.example.com/dev]
-p, --port <PORT> Local service port to forward to [default: 3000]
--host <HOST> Local service host [default: 127.0.0.1]
-t, --token <TOKEN> Authentication token (JWT)
-v, --verbose Enable verbose logging
--connect-timeout <SECS> Connection timeout in seconds [default: 10]
--request-timeout <SECS> Request timeout in seconds [default: 25]
Environment Variables:
TUNNEL_ENDPOINT: Override default WebSocket endpointTUNNEL_TOKEN: Set authentication tokenEdit infra/Pulumi.dev.yaml:
config:
aws:region: us-west-2
aws:profile: your-aws-profile
http-tunnel:environment: dev
http-tunnel:lambdaArchitecture: arm64
http-tunnel:lambdaMemorySize: "256"
http-tunnel:lambdaTimeout: "30"
http-tunnel:enableCustomDomain: "false"
See infra/README.md for all configuration options.
Approximate monthly costs (us-west-2 region):
| Service | Usage | Cost |
|---|---|---|
| Lambda | 1M requests, 256MB, 500ms avg | ~$3.00 |
| API Gateway WebSocket | 1M messages | ~$1.00 |
| API Gateway HTTP | 1M requests | ~$1.00 |
| DynamoDB | 1M reads, 100K writes | ~$0.50 |
| Custom Domains | 2 domains (optional) | ~$2.00 |
| Total | ~$5.50-7.50 |
AWS Free Tier may significantly reduce costs for development/testing usage.
The deployed infrastructure includes CloudWatch logs for:
Access logs via AWS Console or CLI:
# View Lambda logs
aws logs tail /aws/lambda/http-tunnel-handler-dev --follow
# View API Gateway logs
aws logs tail /aws/apigateway/http-tunnel-dev --follow
Problem: Agent can't connect to WebSocket endpoint
Solution:
wss://)make deploy-infra)Problem: HTTP requests timeout waiting for response
Solution:
Problem: Custom domain not resolving or returns errors
Solution:
Contributions are welcome! Please:
cargo test)cargo clippy)| Feature | HTTP Tunnel | ngrok |
|---|---|---|
| Deployment | Self-hosted (AWS) | SaaS |
| Cost | Pay AWS costs (~$5) | Free/$10-$35/month |
| Custom Domain | β Included | β (paid plans) |
| Open Source | β MIT License | β Proprietary |
| Data Privacy | Your AWS account | ngrok servers |
| Scaling | Auto (serverless) | Managed by ngrok |
| Setup Complexity | Medium (AWS + Rust) | Easy (download & run) |
For production use, consider:
This project is distributed under the terms of MIT.
See LICENSE for details.
Copyright 2025 Tyr Chen
Inspired by ngrok and built with: