πΉ Gopher
Public router for private services. Self-hosted reverse tunnel system with automatic HTTPS and subdomain routing. Expose homelab services, research servers, or any private machine via clean URLs - no port forwarding needed.
Example:
photos.yourdomain.com β Immich on home NAS (192.168.1.50:2283)
lab.yourdomain.com β Jupyter on university server (no public IP)
vault.yourdomain.com β Bitwarden on Raspberry Pi (behind NAT)
How It Works
Run Gopher on a VPS. It manages Caddy (reverse proxy) and rathole (tunnel server). Private machines establish outbound tunnels. Gopher routes incoming traffic by subdomain.
Internet
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β Public VPS (Gopher runs here) β
β β
β βββββββββββββββββββ βββββββββββββββββββββββ β
β β Caddy (80/443) β β rathole server β β
β β auto-HTTPS ββββΆβ (port 2333) β β
β β subdomainβport β β tunnels listening β β
β βββββββββββββββββββ ββββββββββ¬βββββββββββββ β
βββββββββββββββββββββββββββββββββ-ββββββββββββββββββ
β outbound TCP tunnel
ββββββββββββββββ
β
ββββββββββ΄βββββββββββββββββββββββββββββββββββ
β Private network (home/lab/office) β
β β
β ββββββββββββββββ ββββββββββββββββββββ β
β β Immich VM β β Bitwarden VM β β
β β rathole cli β β rathole cli β β
β β :2283 β β :80 β β
β ββββββββββββββββ ββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββ
Traffic flow: photos.yourdomain.com β Caddy (VPS) β rathole tunnel β rathole client β localhost:2283 (Immich)
Key insight: Machines connect outbound to VPS (bypasses firewalls). VPS routes incoming requests through established tunnels.
Quick Start
Prerequisites
- VPS: Any cloud provider (Oracle, AWS, Hetzner) with Ubuntu/Debian
- Domain: Point DNS A record to your VPS IP
- Build tools: Go 1.21+ and Node.js 18+
Installation
# Build
git clone https://github.com/smalex-z/gopher.git
cd gopher
./scripts/build.sh # Builds frontend + Go binary
# Run
./gopher
# On first start, Gopher may prompt once for your sudo password
# to configure passwordless sudo for local service management.
# Optional: install as a systemd service
./gopher install
# In setup, you can optionally check "Skip Caddy / reverse proxy"
# to run rathole-only mode (no domain/subdomain URL routing).
# Service management
sudo systemctl status gopher
sudo systemctl restart gopher
# Uninstall service and installed paths
./gopher uninstall
# During uninstall, Gopher prompts whether to reset or fully remove
# Caddy and rathole.
# Open http://localhost:8080
Setup Workflow
1. Configure Server (Server tab)
- Enter VPS IP/hostname
- Provide SSH credentials (user + private key)
- Enter your domain (e.g.,
example.com)
- Click Install Server β Gopher installs Caddy + rathole on VPS
2. Add Machines (Machines tab)
- Click Bootstrap New Machine
- Copy the one-liner command
- SSH to your private machine and run it
- Machine establishes reverse tunnel to VPS
3. Create Tunnels (Tunnels tab)
- Select machine from dropdown
- Enter subdomain (e.g.,
photos)
- Enter local port (e.g.,
2283 for Immich)
- Click Create Tunnel
Done! https://photos.example.com is live with automatic TLS.
Use Cases
Homelab:
photos.home.com β Jellyfin media server
vault.home.com β Bitwarden password manager
files.home.com β Nextcloud file sync
monitor.home.com β Grafana dashboards
Research Lab:
jupyter.lab.edu β Jupyter notebook server
vnc1.lab.edu β VNC to lab computer 1
vnc2.lab.edu β VNC to lab computer 2
data.lab.edu β Dataset browser
Multi-Network:
nas.alexzheng.com β Home NAS (Maryland)
jupyter.alexzheng.com β Lab server (UCLA)
media.alexzheng.com β Friend's Plex (shared server)
All managed from one dashboard, all accessible via clean URLs.
Project Structure
gopher/
βββ cmd/server/
β βββ main.go # Entry point; embeds frontend
β βββ frontend/dist/ # Compiled React app
βββ frontend/ # React + TypeScript + Tailwind
β βββ src/
β βββ pages/ # Dashboard, Machines, Tunnels, Server
β βββ components/ # UI components
βββ internal/
β βββ api/ # Chi router + handlers
β βββ config/ # Caddyfile + rathole TOML generation
β βββ db/ # SQLite (GORM) models + migrations
β βββ service/ # Business logic
β βββ ssh/ # SSH client + deploy scripts
βββ scripts/
βββ build.sh # Build script
βββ dev.sh # Dev mode (hot reload)
Tech Stack
Backend:
- Go 1.21+ - Single binary, great for SSH/networking
- Chi router - Lightweight HTTP router
- GORM + glebarez/sqlite - Pure Go SQLite (no CGO)
- golang.org/x/crypto/ssh - SSH for VPS management
Frontend:
- React 18 + TypeScript - Component-based UI with type safety
- Vite - Lightning-fast dev server
- Tailwind CSS - Utility-first styling
- Embedded via
//go:embed - Single binary distribution
Infrastructure (deployed by Gopher):
- Caddy 2 - Reverse proxy with automatic HTTPS
- rathole - Lightweight TCP tunnel (Rust-based)
Development
# Development mode (hot reload)
./scripts/dev.sh
# Frontend: http://localhost:5173
# Backend: http://localhost:8080
# Production build
./scripts/build.sh
./gopher
VPS Recommendations
Tested providers:
- Oracle Cloud: Free tier (4 vCPU ARM, 24GB RAM, 4 Gbps) - perfect for Gopher
- Hetzner: β¬3.79/month - reliable and cheap
- DigitalOcean: $6/month droplet works well
- AWS EC2: t2.micro (free tier eligible)
- Not recommended because of miserable networking (~0.05 Gbps)
Minimum specs: 1 vCPU, 1GB RAM handles ~10 tunnels
Required ports open: 22 (SSH), 80 (HTTP), 443 (HTTPS), 2333 (rathole)
Comparison
|
Gopher |
ngrok |
Cloudflare Tunnel |
Port Forwarding |
| Cost |
VPS (~$3-5/mo) |
$8-20/mo |
Free* |
None |
| Custom domain |
β
|
π° Paid tier |
β οΈ CF DNS required |
β
|
| Permanent URLs |
β
|
β Ephemeral |
β
|
β
|
| Self-hosted |
β
|
β |
β |
N/A |
| Vendor lock-in |
β |
β
|
β
|
β |
| Protocol support |
HTTP/TCP/UDP |
HTTP/TCP |
HTTP only** |
All |
| File size limit |
None (VPS disk) |
Varies |
β οΈ 100-500 MB |
None |
| Bandwidth limit |
VPS limit (1-10 TB) |
Plan based |
β οΈ Undefined |
ISP only |
| Request timeout |
Unlimited |
Varies |
β οΈ 100s free |
Unlimited |
| Works behind NAT |
β
|
β
|
β
|
β |
| Automatic HTTPS |
β
|
β
|
β
|
β |
| Traffic privacy |
β
You control |
β ngrok sees all |
β CF sees all |
β
|
| Use case |
Self-hosted services |
Development/demos |
Simple websites |
Home network |
*Free with limitations
**Non-HTTP protocols require Cloudflare Access (paid)
Contributing
Issues and PRs welcome! See issues.
Areas needing help:
- Testing on different VPS providers
- Documentation improvements
- Bug reports and fixes
License
MIT - see LICENSE
Acknowledgments
Built with Caddy, rathole, and inspired by ngrok and Cloudflare Tunnel.