add doc for port range mapping (#4081)

This commit is contained in:
fatedier
2024-03-19 13:22:29 +08:00
committed by GitHub
parent acf33db4e4
commit 002831ea82
3 changed files with 22 additions and 3 deletions

View File

@@ -78,6 +78,7 @@ frp also offers a P2P connect mode.
* [URL Routing](#url-routing)
* [TCP Port Multiplexing](#tcp-port-multiplexing)
* [Connecting to frps via PROXY](#connecting-to-frps-via-proxy)
* [Port range mapping](#port-range-mapping)
* [Client Plugins](#client-plugins)
* [Server Manage Plugins](#server-manage-plugins)
* [SSH Tunnel Gateway](#ssh-tunnel-gateway)
@@ -1158,6 +1159,24 @@ serverPort = 7000
transport.proxyURL = "http://user:pwd@192.168.1.128:8080"
```
### Port range mapping
*Added in v0.56.0*
We can use the range syntax of Go template combined with the built-in `parseNumberRangePair` function to achieve port range mapping.
The following example, when run, will create 8 proxies named `test-6000, test-6001 ... test-6007`, each mapping the remote port to the local port.
```
{{- range $_, $v := parseNumberRangePair "6000-6006,6007" "6000-6006,6007" }}
[[proxies]]
name = "tcp-{{ $v.First }}"
type = "tcp"
localPort = {{ $v.First }}
remotePort = {{ $v.Second }}
{{- end }}
```
### Client Plugins
frpc only forwards requests to local TCP or UDP ports by default.