- README 默认英文:README.en.md → README.md(英文为默认),中文移至 README.zh-CN.md,语言切换链接同步 - 恢复被删除的 docs/en/ 英文文档(git 历史 cc5e53c5^),删除 4 篇已废弃文件 - 英文导航 config.ts 对齐中文结构(新增 Deployment/Changelog 侧栏,同步 Guide/Design 条目) - 翻译 15 篇中文新增文档:guide 5 篇(certificates/pages-usage/proxy-config/uptime-kuma/zone-domain-migration)+ design 10 篇(zone-design/cloudflare-pointing/waf-orchestration/origin-error-page/edge-cache-design/pages-design/logstore/kuma-design/login-captcha/observability 三篇) - en 首页更新(新增 Pages 特性、tagline 同步);changelog 英文入口指向中文版 - vitepress 构建验证:43 个英文页面全部渲染 注意:29 篇旧英文文档为恢复版,部分内容(如 deployment/server、reference/configuration)可能落后于中文,需后续逐篇同步
11 KiB
Tunnel & Intranet Penetration
You will learn: The design principles of OpenFlare intranet penetration tunnels, core concepts (Relay nodes and Tunnel clients), and how to safely and stably publish your intranet development environment or private cloud services to a public domain name from scratch.
In many practical development and operations scenarios, our origin servers are deployed in local LANs, local development machines, or heavily guarded private VPCs, having no public IP address and no port mapping (NAT) configured on border firewalls or routers.
OpenFlare provides an end-to-end solution based on reverse relay penetration tunnels. You only need to initiate a secure outbound connection from your intranet environment to the public relay node, without configuring any inbound ports, to smoothly route public web traffic into your intranet origin. At the same time, you benefit from automatic TLS certificate hosting and WAF security protection provided by the gateway.
Core Concepts
Before using the intranet penetration features, you need to familiarize yourself with the following components and core concepts:
| Concept | Description | Component / Operation |
|---|---|---|
| Relay Node (Relay) | Traffic relay services deployed at the public edge, responsible for listening to intranet client persistent connections, acting as the transit bridge between the gateway Agent (OpenResty) and internal traffic. | Node of type tunnel_relay running the openflare-relay daemon |
| Penetration Tunnel (Tunnel) | Logical penetration client instances having a globally unique ID and secure authentication token, used to identify a specific intranet environment. | Globally unique ID generated by Server tunnel_id (format: tun-<32hex>) |
| Tunnel Client (Client) | A lightweight controller running in the intranet environment, automatically managing the underlying frpc tunnel subprocesses according to the configuration dispatched by the Server. | The openflared container or independent binary process deployed in the intranet |
| Tunnel Upstream (Tunnel Upstream) | A special upstream type in the website configuration. When this type is selected, the gateway forwards public traffic to the Vhost port of the local relay node, eventually reaching the intranet origin. | Upstream of type tunnel configured in the website details |
Recommended Operation Sequence
To publish an intranet service to the public internet, we recommend doing so in the following order:
- Register and deploy at least one public Relay Node (Relay) and keep it online.
- Create a Penetration Tunnel (Tunnel) in the management console and copy its dedicated Token.
- Deploy and start the Tunnel Client (OpenFlared) on your intranet server.
- Confirm that the status of the tunnel in the management console shows as "Online".
- Add a website configuration, selecting Intranet Penetration as the upstream type, binding it to the corresponding tunnel, and entering the intranet port (e.g.,
127.0.0.1:8080). - Publish and activate the new version.
- Access via the public domain to verify that the intranet penetration link is established.
Detailed Configuration Steps
Step 1: Prepare the Relay Node (Relay)
Intranet traffic is routed through public relay nodes. Before starting, ensure you have a public relay server available.
-
Log into the management console and go to "Node Management".
-
Add a new node, selecting Relay Node (tunnel_relay) as the Node Type.
-
Save and copy the node-specific
agent_token. -
Start the
openflare-relayprocess on your public server. You can run it quickly using Docker:docker run -d --name openflare-relay --restart unless-stopped \ -p 7000:7000 \ -e OPENFLARE_SERVER_URL=http://<YOUR_SERVER_PUBLIC_IP>:3000 \ -e OPENFLARE_AGENT_TOKEN=<YOUR_COPIED_AGENT_TOKEN> \ -v openflare-relay-data:/var/lib/openflare-relay \ ghcr.io/rain-kl/openflare-relay:latestImportant
Make sure to allow port
7000(the control port for frpc client connections) in your cloud provider's security group. If your Server and Relay are deployed on the same machine,OPENFLARE_SERVER_URLshould point to the Server's public or internal IP.
Step 2: Create a Penetration Tunnel in the Management Console
- Navigate to the "Intranet Penetration" section in the side navigation bar.
- Click the "Create Tunnel" button and enter:
- Tunnel Name: Describes the intranet environment, e.g.,
home-laboroffice-dev. - Description: Optional, describes the purpose of this tunnel.
- Tunnel Name: Describes the intranet environment, e.g.,
- Click save, and the system will automatically generate a globally unique ID and a dedicated
tunnel_token(e.g.,tun-xxxx...). - Copy the Client Deployment Command generated in the popup window, which will be used in the next step.
Step 3: Deploy the Intranet Client (OpenFlared)
Return to your intranet server and execute the copied deployment command to run the client.
Option A: Deploy with Docker (Highly Recommended)
The official openflared image embeds the master daemon and frpc runtime, working out-of-the-box with no extra dependencies:
docker run -d --name openflared --restart unless-stopped \
-e OPENFLARE_SERVER_URL=http://<YOUR_SERVER_PUBLIC_IP>:3000 \
-e OPENFLARE_TUNNEL_TOKEN=<YOUR_COPIED_TUNNEL_TOKEN> \
-v openflared-data:/app/data \
ghcr.io/rain-kl/openflared:latest
Option B: Host Binary Manual Execution
If you cannot use Docker, you can download or compile the flared binary:
- Create a
flared.jsonconfiguration file in the same directory as the executable on your intranet machine:{ "server_url": "http://<YOUR_SERVER_PUBLIC_IP>:3000", "tunnel_token": "<YOUR_COPIED_TUNNEL_TOKEN>", "frpc_path": "/usr/local/bin/frpc", "data_dir": "./data" } - Execute the startup command:
./flared -config ./flared.json
Verify Online Status
Once started successfully, the intranet client will send heartbeats through outbound networks to synchronize configurations. At this point:
- Refresh the "Intranet Penetration" list in the management console; the tunnel status indicator should turn green and show "Online".
- Click tunnel details to view which public Relays the intranet client is currently connected to.
Step 4: Create a Website and Bind the Tunnel Upstream
Now you can configure public reverse proxy and domain routing for your intranet service.
- Go to the "Website Configuration" page and click "Create Website".
- Enter the Domain Name required to access the service publicly, e.g.,
nas.example.com. - Critical Configuration: In the "Upstream Configuration" section, switch the Upstream Type from "Direct" to "Intranet Penetration".
- In the dropdown list, select your newly deployed Intranet Tunnel (e.g.,
home-lab). - Enter the Intranet Target Address (the local address and port reachable by the intranet client, e.g.,
127.0.0.1:8080) and select the Intranet Protocol (usuallyhttp). - Configure other standard website settings (such as TLS certificates) and click save.
Step 5: Publish & Activate
To allow the gateway's OpenResty instance to match and route domain traffic correctly, we need to publish a new configuration version.
- Click "Preview Config" in the top right corner of the navigation bar to verify the generated configurations.
- In the popup window, click "Publish & Activate".
- Now, the public edge Agent pulls the latest routing, forwarding requests for
nas.example.comto the loopback virtual host port ofopenflare-relay (frps). - The intranet client
openflared (frpc)receives the relayed packets, securely hands them over to the local127.0.0.1:8080service, and returns responses back through the tunnel. - Access
nas.example.comin your browser to confirm that the intranet service displays successfully!
Advanced Application Scenarios
1. Single-Tunnel Multi-Service Multiplexing (Multi-Port Mapping)
You do not need to deploy an openflared container for every single internal service.
If you want to map multiple different services in the same intranet environment (e.g., 127.0.0.1:80 for a blog, 127.0.0.1:8080 for an API, and 192.168.1.120:9000 for a local network drive):
- Keep this single
openflaredclient online. - Create three independent website configurations in the management console (binding their respective public domains).
- Set the Upstream Type to the same intranet tunnel for all three website configurations.
- Fill in their respective "Intranet Target Addresses" (e.g.,
127.0.0.1:80,127.0.0.1:8080, and192.168.1.120:9000). - Publish and activate the new version to achieve single-tunnel multi-service multiplexing.
2. Seamless Integration with Gateway Security Features
Since all public traffic enters the public Agent node first, completing the HTTPS/TLS handshake and WAF filtering before traveling through the secure tunnel:
Your intranet services naturally benefit from the following advanced features without any code changes:
- One-Click HTTPS: Select or issue SSL certificates directly in the management console, encrypting transmission end-to-end.
- Global/Custom WAF Protections: Enables SQL injection blocking, XSS prevention, and regional IP filtering.
- Human-Machine Challenge (PoW CC): Instantly blocks brute-force CC API attacks targeting your intranet services.
Common Troubleshooting
1. Tunnel Shows as "Offline" in the Management Console
- Check the Token: Check if the
tunnel_tokenconfigured inflaredlogs or environment variables matches the one generated in the management console. - Check Outbound Connectivity: The intranet server must be able to make outbound requests to the Server address. Ensure the control plane firewall is not blocking HTTP requests from the client.
- Relay Firewall Port Closed: Check if port
7000(or your custom bindPort) on the public Relay node has been allowed in the public security groups.
2. Accessing the Public Domain Returns 502 Bad Gateway / 504 Gateway Timeout
- Intranet Service Not Running: Verify that the service corresponding to the intranet target address is running and listening on the intranet server.
- Target Address Unreachable: If the intranet address is set to
127.0.0.1:8080, ensure the service is running on the exact same host asopenflared; if set to a LAN IP192.168.x.x, test connectivity to that IP inside theopenflaredcontainer. - Check Client Application Logs: View the "Apply Logs" in the management console or inspect local
flaredlogs for anyLastError. When frpc fails to connect to the intranet port, it reports the failure details to the Server.
3. Multiple Relays Network Instability or Retry Failures
- When the control plane associates multiple Relay nodes,
openflaredspawns independent frpc daemon processes for each Relay and pulls topology states periodically atsync_interval(default 30s) configured inflared.json. - If a Relay drops frequently due to network jitter, the system triggers the backoff retry mechanism automatically. You can see
frpc process missing, startinglogs on the host, which is a normal process self-healing action and will recover within 5-10 seconds after network recovery.