golocalport

module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2026 License: MIT

README ΒΆ

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:

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:

  1. Account ID & Zone ID: Found in Cloudflare Dashboard β†’ Your Domain β†’ Overview
  2. API Token: Dashboard β†’ Profile β†’ API Tokens β†’ Create Token
    • Permissions needed: Cloudflare Tunnel (Edit) + DNS (Edit)
  3. 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

  1. You run golocalport 3000 -s myapp
  2. GoLocalPort creates a Cloudflare Tunnel
  3. DNS record is created: myapp.golocalport.link β†’ Cloudflare Edge
  4. Cloudflared connects your localhost:3000 to Cloudflare
  5. Traffic flows through Cloudflare's network to your machine
  6. 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.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT License - Feel free to use GoLocalPort in your projects!

Acknowledgments


Made with ❀️ using Go

Directories ΒΆ

Path Synopsis
cmd
golocalport command
internal
api
ui

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL