mgrok-cli
v1.0.3
Published
Secure tunneling service for exposing local services to the internet
Maintainers
Readme
MGrok CLI - Secure Tunneling Service
MGrok CLI is a powerful and secure tunneling service that allows you to expose local services to the internet with ease. Perfect for development, testing, webhook integration, and remote access.
Installation
Global Installation (Recommended)
npm install -g mgrok-cliLocal Installation
npm install mgrok-cliQuick Start
After installation, you can start using MGrok immediately:
# Login to your account
mgrok login
# Start a tunnel for a local web server
mgrok http 8080
# Start a tunnel with custom domain
mgrok http 8080 --url=custom.yourdomain.com
# Start a TCP tunnel for SSH
mgrok tcp 22
# Start a UDP tunnel for DNS
mgrok udp 53Features
- 🚀 Easy to Use - Simple command-line interface
- 🔒 Secure - HTTPS tunnels with SSL certificates
- 🌍 Global - Fast servers worldwide (Brazil region)
- 📊 Real-time Monitoring - Web interface with connection logs
- 🔧 Advanced Options - Remote host forwarding, custom domains
- 💳 Free Tier Available - Generous free plan
- 🎯 Subdomain Support - Use custom subdomains
- 📱 Cross-Platform - Windows, macOS, Linux, FreeBSD
- 🔄 Auto-reconnect - Automatic tunnel recovery
- 📈 Request Logging - Real-time HTTP request tracking
Commands
Authentication
# Login to your MGrok account
mgrok login
# Logout from current account
mgrok logout
# Check login status
mgrok statusHTTP Tunnels
# Basic HTTP tunnel (localhost)
mgrok http 8080
# HTTP tunnel for remote host
mgrok http 80 192.168.1.100
# HTTP tunnel with custom domain
mgrok http 8080 --url=custom.yourdomain.com
# HTTP tunnel for remote host with custom domain
mgrok http 80 192.168.1.100 --url=remote.yourdomain.comTCP Tunnels
# Basic TCP tunnel (localhost)
mgrok tcp 22
# TCP tunnel with subdomain
mgrok tcp 22 myapp.mgrok.app
# TCP tunnel for remote host
mgrok tcp 22 192.168.1.100
# TCP tunnel with custom domain
mgrok tcp 22 custom.domain.comUDP Tunnels
# Basic UDP tunnel (localhost)
mgrok udp 53
# UDP tunnel with subdomain
mgrok udp 53 dns.mgrok.app
# UDP tunnel for remote host
mgrok udp 53 192.168.1.100
# UDP tunnel with custom domain
mgrok udp 53 custom.domain.comManagement
# List all active tunnels
mgrok list
# Check for updates
mgrok update
# Show help
mgrok --helpUsage Examples
Web Development
# Expose local development server
mgrok http 3000
# Result: https://random-subdomain.mgrok.app
# Web Interface: http://127.0.0.1:4000 (for monitoring)Remote SSH Access
# Expose SSH server for remote access
mgrok tcp 22
# Result: tcp://random-subdomain.mgrok.app:portDatabase Access
# Expose local database
mgrok tcp 5432
# Access remotely: psql -h random-subdomain.mgrok.app -p port -U usernameWebhook Testing
# Test webhooks from external services
mgrok http 8080 --url=webhook.yourdomain.com
# External services can send webhooks to: https://webhook.yourdomain.comRemote Device Access
# Access service on remote device in local network
mgrok http 80 192.168.1.50
# Access service on remote device via internet
mgrok tcp 22 device.mgrok.appWeb Interface
When you start an HTTP tunnel, MGrok automatically provides a web interface for monitoring:
- URL:
http://127.0.0.1:4000(port varies based on local port) - Features:
- Real-time connection monitoring
- HTTP request logs with status codes
- IP address tracking
- User agent information
- Connection statistics
Configuration
Config File Location
MGrok stores configuration in:
- macOS:
~/Library/Application Support/mgrok/config.json - Linux:
~/.config/mgrok/config.json - Windows:
%APPDATA%\mgrok\config.json
Environment Variables
MGROK_SERVER_URL- API server URL (default: https://api.mgrok.app)MGROK_LOG_LEVEL- Log level (info, debug, error)
Advanced Features
Remote Host Forwarding
Forward traffic to a different host in your network:
# Forward to another machine in local network
mgrok http 80 192.168.1.100
# Forward to service in Docker container
mgrok http 8080 172.17.0.2
# Forward TCP service on remote host
mgrok tcp 3306 database.localCustom Domains
Use your own domain with MGrok:
# Requires domain configuration in your MGrok account
mgrok http 8080 --url=api.yourdomain.com
mgrok tcp 22 --url=ssh.yourdomain.comSubdomain Forwarding
Use MGrok subdomains for organized access:
# TCP tunnel with subdomain
mgrok tcp 22 myssh.mgrok.app
# UDP tunnel with subdomain
mgrok udp 53 dns.mgrok.appTroubleshooting
Common Issues
"You need to login first"
mgrok loginPort already in use
- Check if the local port is available
- Use a different local port number
Connection refused
- Verify your local service is running
- Check if the port number is correct
- Ensure firewall allows the connection
Remote host not accessible
- Verify network connectivity to remote host
- Check if remote service is running
- Ensure firewall allows remote access
Debug Mode
Enable verbose logging for troubleshooting:
# Check connection status
mgrok status
# Monitor web interface for request logs
# Access: http://127.0.0.1:4000API Integration
MGrok CLI can be used programmatically:
const { spawn } = require('child_process');
// Start HTTP tunnel
const tunnel = spawn('mgrok', ['http', '8080']);
tunnel.stdout.on('data', (data) => {
console.log(`Tunnel output: ${data}`);
});
// Stop tunnel
tunnel.kill('SIGINT');Updates
MGrok CLI automatically checks for updates:
# Check for updates manually
mgrok update
# The CLI will notify you if updates are available
# Follow the instructions to upgradeSecurity
- 🔒 All HTTP tunnels use HTTPS by default
- 🔑 Authentication required for tunnel creation
- 🛡️ SSH key-based tunnel connections
- 🔒 Encrypted communication between client and server
- 📝 Request logging for security monitoring
Platform Support
MGrok CLI supports the following platforms:
- Windows (x64, ARM64)
- macOS (Intel, Apple Silicon)
- Linux (x64, ARM64, ARM)
- FreeBSD (x64)
Support
- 📖 Documentation
- 🐛 Issues
- 💬 Discord
License
MIT License - see LICENSE file for details.
Version: 1.0.1
Region: Brazil (São Paulo)
Web Interface: Real-time monitoring and logging
