Guide to Configuring Ngrok Reverse Proxy Service in ServBay
Ngrok is a secure tunnel tool based on reverse proxy technology, capable of penetrating firewalls to map local services to the public network. This guide will detail how to deploy Ngrok in the ServBay environment to enable internet access to local web services.
Technical Principles
Ngrok creates an encrypted tunnel connection, mapping local services behind NAT/firewalls to a public domain name. In the ServBay application scenario, this solution allows developers to publish web services that are being debugged locally in real-time, facilitating team collaboration and remote testing.
Environment Preparation
1. Installing the Ngrok Client
Follow these steps to deploy the Ngrok CLI tool:
- Visit the official download page to obtain the installation package for your system.
- Unzip and deploy it to the system PATH directory (using macOS ARM architecture as an example):bash
sudo unzip ~/Downloads/ngrok-v3-stable-darwin-arm64.zip -d /usr/local/bin
1 - Verify installation integrity:bash
ngrok version # ngrok version 3.5.0
1
2
Practical Tunnel Configuration
Core Parameter Explanation
The standard command structure for executing service mapping is as follows:
ngrok http --domain=<NGROK_DOMAIN> <LOCAL_ENDPOINT> \
--request-header-add='host: <VIRTUAL_HOST>'
2
Parameter Component | Function Description |
---|---|
http | Declares an HTTP protocol tunnel |
--domain | Specifies the fixed domain name allocated by Ngrok (replace with actual domain) |
<LOCAL_ENDPOINT> | Local ServBay service address (default is https://servbay.host ) |
--request-header-add | Rewrites the Host header to ensure correct request routing |
Configuration Example
Assuming you want to map the local service servbay.local
to the public domain cunning-lacewing-fresh.ngrok-free.app
, execute the command:
ngrok http --domain=cunning-lacewing-fresh.ngrok-free.app https://servbay.local \
--request-header-add='host: servbay.local'
2
After successful execution, the terminal will display tunnel status information, including the public access address and real-time traffic monitoring.
Service Verification
After configuration, verify by following these steps:
- Access the Ngrok domain in your browser:
https://cunning-lacewing-fresh.ngrok-free.app
1 - Expected results:
- Displays web content consistent with the local service
- Valid HTTPS connection security indicator
- Response time within a reasonable range (typically <500ms)
Figure: Website page accessed through Ngrok
Advanced Tips
Domain Management:
- Apply for custom domain names in the Ngrok Dashboard.
- Enterprise users can bind their own domain names (requires upgrading to a paid plan).
Multi-Service Mapping:
bash# Map both HTTP/HTTPS services simultaneously ngrok http --domain=your-domain.ngrok.app 80 ngrok tls --domain=your-domain.ngrok.app 443
1
2
3Diagnostic Commands:
bashngrok config check # Verify configuration file ngrok logs # View real-time logs
1
2
Troubleshooting
Phenomenon | Solution |
---|---|
Connection timeout | Check the status and port occupancy of ServBay services |
HTTPS certificate error | Ensure --request-header-add parameter is configured correctly |
Intermittent disconnection | Verify network stability, recommended to use a wired connection |
Solution Summary
By using the Ngrok reverse proxy solution, developers can quickly establish a secure public access channel in the ServBay environment. This configuration offers the following advantages:
- Zero-code transformation for service exposure
- Supports real-time traffic monitoring and analysis
- Provides enterprise-grade security protection (requires configuring access policy)
It is recommended to use the paid version of Ngrok in production environments for more stable service assurance.