GoLocalPort
π A lightweight, high-performance ngrok alternative written in Go
GoLocalPort creates secure HTTP/HTTPS tunnels from your localhost to public URLs using Cloudflare's global edge network. Built with Go for speed, simplicity, and a tiny footprint.
Features
- β‘ Instant Setup: One command to expose your localhost
- π Custom Subdomains: Choose your own URL (e.g.,
myapp.golocalport.link)
- π Automatic HTTPS: SSL/TLS encryption via Cloudflare
- π Global Edge Network: Fast connections worldwide
- π» Cross-Platform: Windows, macOS, and Linux
- π 100% Free: No accounts, no limits
- π Open Source: MIT licensed
Why Go?
- Small Binary: Single executable, no runtime dependencies
- Fast: Quick startup and low memory usage
- Concurrent: Native goroutines for handling connections
- Simple: Clean, idiomatic Go code
Installation
From Source
go install github.com/devshark/golocalport/cmd/golocalport@latest
Note: Use @latest or @v0.1.1 or higher.
From Release
Download the latest binary from releases.
Backend Setup (Required)
GoLocalPort requires a backend server to manage Cloudflare Tunnels. You have two options:
Option 1: Deploy Your Own (Recommended)
The server/ directory contains a minimal Go backend server.
Quick Deploy to Fly.io (Free):
cd server
# Install flyctl
curl -L https://fly.io/install.sh | sh
# Login and deploy
fly auth login
fly launch --name golocalport-server
# Set your Cloudflare credentials
fly secrets set \
CF_ACCOUNT_ID=your_account_id \
CF_ZONE_ID=your_zone_id \
CF_API_TOKEN=your_api_token \
CF_DOMAIN=yourdomain.com
fly deploy
Get Cloudflare Credentials:
- Account ID & Zone ID: Found in Cloudflare Dashboard β Your Domain β Overview
- API Token: Dashboard β Profile β API Tokens β Create Token
- Permissions needed: Cloudflare Tunnel (Edit) + DNS (Edit)
- Domain: Your domain managed by Cloudflare
Other deployment options: See server/DEPLOY.md for Railway, Docker, VPS, etc.
Option 2: Use Public Backend (Testing Only)
For quick testing, you can use the public backend:
golocalport 3000 -b https://api.golocalport.link
β οΈ Note: Public backend uses golocalport.link domain and may have rate limits.
Configuration
After deploying your backend, update the default:
Edit internal/config/config.go:
const (
DefaultBackend = "https://your-server-url"
)
Then rebuild:
go build -o golocalport cmd/golocalport/main.go
Quick Start
Expose port 3000 with a random subdomain:
golocalport 3000
With a custom subdomain:
golocalport 3000 -s myapp
# Creates: https://myapp.golocalport.link
Usage
golocalport [port] [flags]
Flags:
-s, --subdomain string Custom subdomain
-b, --backend string Backend URL (default: https://api.golocalport.link)
-v, --version Show version
-h, --help Show help
Examples
Web Development
# Next.js
npm run dev
golocalport 3000 -s my-nextjs-app
# React
npm start
golocalport 3000 -s my-react-app
Webhook Testing
# Start your webhook receiver
node webhook-receiver.js
# Expose it
golocalport 4000 -s my-webhooks
# Use in GitHub webhook settings:
# https://my-webhooks.golocalport.link/webhook
How It Works
- You run
golocalport 3000 -s myapp
- GoLocalPort creates a Cloudflare Tunnel
- DNS record is created:
myapp.golocalport.link β Cloudflare Edge
- Cloudflared connects your localhost:3000 to Cloudflare
- Traffic flows through Cloudflare's network to your machine
- On exit (Ctrl+C), tunnel and DNS are cleaned up
Internet β Cloudflare Edge β Cloudflare Tunnel β Your localhost:3000
(https://myapp.golocalport.link)
Development
# Clone the repository
git clone https://github.com/devshark/golocalport.git
cd golocalport
# Build
go build -o golocalport cmd/golocalport/main.go
# Run
./golocalport 3000
Project Structure
golocalport/
βββ cmd/
β βββ golocalport/
β βββ main.go # Entry point
βββ internal/
β βββ api/ # Backend API client
β βββ binary/ # Cloudflared management
β βββ config/ # Configuration
β βββ state/ # State management
β βββ tunnel/ # Tunnel orchestration
β βββ ui/ # User interface
βββ server/ # Backend server (deploy separately)
β βββ main.go # HTTP server
β βββ cloudflare.go # Cloudflare API client
β βββ Dockerfile # Docker support
β βββ DEPLOY.md # Deployment guide
βββ go.mod
βββ go.sum
βββ README.md
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -m 'Add amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
License
MIT License - Feel free to use GoLocalPort in your projects!
Acknowledgments
Links
Made with β€οΈ using Go