How to Build Your Own Ngrok Alternative with FRP (Ubuntu, Windows, Mac)
Tired of Ngrok’s limitations? Need to expose your local development server to the internet for webhooks, testing, or demonstrations without paying a subscription? Look no further! This comprehensive guide will walk you through setting up a robust, open-source tunneling solution using FRP (Fast Reverse Proxy) on an Ubuntu VPS, complete with HTTPS, custom domains, and an admin dashboard. We’ll cover clients for Windows, macOS, and Linux.
Why FRP?
- Open Source & Free: No recurring costs, full control.
- High Performance: Written in Go, designed for efficiency.
- Custom Domains: Use your own subdomains (e.g.,
ngrok.yourdomain.com). - HTTPS Support: Secure your tunnels with Let’s Encrypt via Nginx.
- Admin Dashboard: Monitor active connections and traffic.
- Cross-Platform: Clients for Windows, macOS, and Linux.
- An Ubuntu 20.04+ VPS (e.g., DigitalOcean, Vultr, AWS EC2).
- A domain name with DNS access (e.g.,
codeboxr.com). - Basic Linux command-line familiarity.
- Nginx already installed on your Ubuntu VPS (or follow Nginx setup guide).
- Certbot (Let’s Encrypt) installed for Nginx.
Part 1: FRP Server Setup (Ubuntu VPS)
This section covers installing and configuring the FRP server (frps) on your Ubuntu VPS.
1.1. Download and Extract FRP
First, log into your Ubuntu VPS via SSH. Download the latest FRP release from GitHub. Always check the releases page for the newest version.
# Check for latest version at https://github.com/fatedier/frp/releases
FRP_VERSION="0.61.1" # Adjust if a newer version is available
wget https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_linux_amd64.tar.gz
tar -zxvf frp_${FRP_VERSION}_linux_amd64.tar.gz
cd frp_${FRP_VERSION}_linux_amd64
1.2. Organize FRP Files
Move the frps binary to a system-wide path and create a dedicated directory for its configuration.
sudo cp frps /usr/bin/
sudo mkdir -p /etc/frp
sudo cp frps.toml /etc/frp/
frps and frps.toml on the server. The frpc (client) files are for your local machines.
1.3. Configure frps.toml
Edit the server configuration file. This defines how frps listens for clients and handles HTTP traffic. Use a strong auth.token!
sudo nano /etc/frp/frps.toml
bindPort = 7000 # Port frpc (client) connects to
vhostHTTPPort = 8080 # Internal port for Nginx to proxy HTTP traffic to
auth.token = "YOUR_SUPER_SECURE_TOKEN" # CHANGE THIS to a strong unique value!
# Dashboard configuration (optional, but highly recommended)
webServer.addr = "127.0.0.1" # Listen only on localhost (Nginx will proxy)
webServer.port = 7500 # The port for the dashboard
webServer.user = "admin" # Dashboard username
webServer.password = "YOUR_DASHBOARD_PASSWORD" # CHANGE THIS!
Save and exit (Ctrl+O, Enter, Ctrl+X).
1.4. Create a Systemd Service for frps
This ensures frps runs in the background and starts automatically on reboot.
sudo nano /etc/systemd/system/frps.service
[Unit]
Description=frp server
After=network.target
[Service]
Type=simple
User=nobody
Restart=on-failure
RestartSec=5s
ExecStart=/usr/bin/frps -c /etc/frp/frps.toml
[Install]
WantedBy=multi-user.target
Save and exit.
1.5. Start and Enable FRP Server
Reload systemd, enable the service, and start frps.
sudo systemctl daemon-reload
sudo systemctl enable frps
sudo systemctl start frps
sudo systemctl status frps # Verify it's running (should show "active (running)")
1.6. Configure UFW Firewall
Allow traffic to the FRP server port (7000) and the Nginx HTTP/HTTPS ports.
sudo ufw allow 7000/tcp # For frpc client connections
sudo ufw allow 'Nginx Full' # Allows HTTP (80) and HTTPS (443)
sudo ufw reload
Part 2: Nginx & HTTPS Configuration (Ubuntu VPS)
We’ll use Nginx as a reverse proxy to handle incoming requests on port 80/443, direct them to frps, and secure them with Let’s Encrypt (Certbot).
2.1. DNS Configuration
Create two A Records in your domain registrar’s DNS settings, pointing to your Ubuntu VPS’s public IP address:
ngrok.yourdomain.com->YOUR_VPS_IPngrokdash.yourdomain.com->YOUR_VPS_IP
yourdomain.com with your actual domain name and YOUR_VPS_IP with your server’s public IP.
2.2. Nginx Vhost for Tunnel Endpoint (ngrok.yourdomain.com)
Create an Nginx configuration file for your tunnel’s public endpoint. Certbot will later automatically add HTTPS.
sudo nano /etc/nginx/sites-available/ngrok.yourdomain.com
server {
listen 80;
server_name ngrok.yourdomain.com;
location / {
proxy_pass http://127.0.0.1:8080; # Pass to frps's vhostHTTPPort
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Save and exit.
2.3. Nginx Vhost for Admin Dashboard (ngrokdash.yourdomain.com)
Create another Nginx config for your FRP dashboard. We’ll proxy to frps’s webServer.port.
sudo nano /etc/nginx/sites-available/ngrokdash.yourdomain.com
server {
listen 80;
server_name ngrokdash.yourdomain.com;
location / {
proxy_pass http://127.0.0.1:7500; # Pass to frps's webServer.port
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Required for FRP dashboard's real-time updates (WebSockets)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Save and exit.
2.4. Enable Nginx Sites and Get SSL
Enable both sites, test Nginx config, reload, and then use Certbot to provision SSL certificates. Choose option 2 (Redirect) for HTTPS redirection.
# Enable sites
sudo ln -s /etc/nginx/sites-available/ngrok.yourdomain.com /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/ngrokdash.yourdomain.com /etc/nginx/sites-enabled/
# Test and reload Nginx
sudo nginx -t
sudo systemctl reload nginx
# Get SSL for both domains (follow prompts)
sudo certbot --nginx -d ngrok.yourdomain.com -d ngrokdash.yourdomain.com
You can now access your FRP dashboard securely at https://ngrokdash.yourdomain.com with the credentials you set in frps.toml.
Part 3: FRP Client Setup (Windows, macOS, Linux)
Now, let’s configure and run the frpc client on your local development machine.
3.1. Download FRP Client
Download the correct FRP client binary for your operating system from the releases page. Extract it to a convenient folder (e.g., C:\frp on Windows, ~/frp on Mac/Linux).
# Example for Linux/macOS (adjust version if needed)
FRP_VERSION="0.61.1"
wget https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_linux_amd64.tar.gz # or darwin_amd64.tar.gz for Mac
tar -zxvf frp_${FRP_VERSION}_linux_amd64.tar.gz
cd frp_${FRP_VERSION}_linux_amd64
frp_xx_windows_amd64.zip, extract, and navigate to the folder in PowerShell.
3.2. Configure frpc.toml
Create an frpc.toml file in your client’s FRP directory. This configuration uses an environment variable for flexible local domain switching.
# frpc.toml
serverAddr = "YOUR_VPS_IP" # Your Ubuntu VPS IP address
serverPort = 7000 # The bindPort from frps.toml
auth.token = "YOUR_SUPER_SECURE_TOKEN" # Must match frps.toml
[[proxies]]
name = "webhooks"
type = "http"
localIP = "127.0.0.1"
localPort = 80 # Your local web server's port (e.g., Laravel Valet/Laragon)
customDomains = ["ngrok.yourdomain.com"] # The public subdomain you configured
hostHeaderRewrite = "{{ .Envs.LOCAL_DEV_DOMAIN }}" # Dynamic local host header
hostHeaderRewrite line is crucial. It tells frpc to change the incoming Host header (ngrok.yourdomain.com) to your local development domain (e.g., localdomain.test) before sending it to your local web server.
3.3. Update Local Hosts File
Ensure your local machine knows where your local development domains are. This usually points them to 127.0.0.1.
- Windows: Open Notepad as Administrator, then open
C:\Windows\System32\drivers\etc\hosts. Add:127.0.0.1 localdomain.test - macOS/Linux: Open Terminal,
sudo nano /etc/hosts. Add:127.0.0.1 localdomain.test
localdomain.test with your actual local development domain.
3.4. Run the FRP Client
Now, run the client, setting the LOCAL_DEV_DOMAIN environment variable on the fly.
Windows (PowerShell)
Open PowerShell as Administrator, navigate to your FRP client folder:
$env:LOCAL_DEV_DOMAIN="localdomain.test"; .\frpc.exe -c frpc.toml
macOS/Linux (Terminal)
Open Terminal, navigate to your FRP client folder:
LOCAL_DEV_DOMAIN="localdomain.test" ./frpc -c frpc.toml
codeboxr.test), just change the LOCAL_DEV_DOMAIN value in the command and re-run it!
Part 4: Verification and Troubleshooting
Verification Steps:
- Client Connected? Look for
start proxy successin your client’s terminal output. - Dashboard Check: Visit
https://ngrokdash.yourdomain.com. Log in, and check the “Proxies” tab. You should see yourwebhookstunnel active. - Browse Public URL: Open your browser to
https://ngrok.yourdomain.com. This should now load your local development site! - Webhook Test: Use a service like Postman or a webhook test tool to send a POST request to your public tunnel URL (e.g.,
https://ngrok.yourdomain.com/api/webhook). Verify it hits your local server.
Common Troubleshooting Tips:
- “unsupported protocol scheme” / “Host header rewrite error”: Double-check your
frpc.toml. EnsurehostHeaderRewriteis directly under[[proxies]]and not nested under a[proxies.plugin]block. Remove any[proxies.plugin]sections. - “connection refused” / “dial tcp…”:
- Server: Check if
frpsis running (sudo systemctl status frps). Ensure firewall port7000is open (sudo ufw status). - Client: Is your local web server (e.g., Apache/Nginx/Artisan) actually running on
127.0.0.1:80?
- Server: Check if
- “502 Bad Gateway” (Nginx): Nginx can’t reach
frps. Verifyfrpsis running and listening on127.0.0.1:8080. Check Nginx error logs:sudo tail -f /var/log/nginx/error.log. - Wrong Content on Public URL:
- Is your
hostHeaderRewritecorrect infrpc.toml? - Is your local
hostsfile correctly configured for your local development domain? - Are you running the correct local web server?
- Is your
Conclusion
You’ve successfully set up a powerful, private, and free localhost tunneling solution using FRP! This setup provides the flexibility and control needed for serious development, allowing you to handle webhooks, test integrations, and share progress effortlessly. Remember to keep your tokens and passwords secure!
FRP Alternative
There are lots of opensoruce alternative for tunnel. Previously we wrote about tunnelto
Need to build a Website or Application?
Since 2011, Codeboxr has been transforming client visions into powerful, user-friendly web experiences. We specialize in building bespoke web applications that drive growth and engagement.
Our deep expertise in modern technologies like Laravel and Flutter allows us to create robust, scalable solutions from the ground up. As WordPress veterans, we also excel at crafting high-performance websites and developing advanced custom plugins that extend functionality perfectly to your needs.
Let’s build the advanced web solution your business demands.