3、作为通道服务
tunnelAnywhere.Frp tunnel
--binding local_address[:local_port]:target_address:target_port
[--server address:port]
[--botnet botnet_name]
[--authenticate-as key-name]
[--ssl-off-loading]
[--keep-http-host]
[--http-host http_host]
--binding 必填,绑定本地地址和远程地址。
local_address 本地地址,例如 127.0.0.1 或 0.0.0.0
local_port 本地端口,可省略,省略会自动获取一个可用的端口
target_address 远端地址
target_port 远端端口
--server 可选,指定穿透服务器地址和端口。
不指定本参数时,程序可不依赖穿透服务器,而单纯提供端口映射功能。
--botnet 可选,指定服务发布者。指定 --server 时,本参数必选。
botnet 服务发布者的唯一 ID。
--authenticate-as 可选参数,指定登录服务器使用的秘钥名称,--server 指定的服务器启用 --authentication-required 时必须提供本参数,key-name 为 newkey 命令指定的值。
--ssl-off-loading 可选参数,用于卸载 HTTPS。
--keep-http-host 可选参数,保持 HTTP 请求头。
--http-host 可选参数,指定 HTTP 请求头,指定本参数时,必须指定 --keep-http-host 参数。
http_host HTTP请求头
指定 --keep-http-host 参数,但没有指定 --http-host 参数时,会自动 target_address 作为 HTTP 请求头
例如:
将本地 1433 映射到 www.baidu.com 的 1433 端口,不依赖任何穿透服务:
Anywhere.Frp tunnel --binding 127.0.0.1:1433:www.baidu.com:1433
将本地 1433 通过被穿透机映射到 www.baidu.com 的 1433 端口:
Anywhere.Frp tunnel --binding 127.0.0.1:1433:www.baidu.com:1433 --server 127.0.0.1:4587 --botnet vDLceacXUkGyPVMOZuf2Hg==
将本地 1433 映射到被穿透机的 1433 端口:
Anywhere.Frp tunnel --binding 127.0.0.1:1433:127.0.0.1:1433 --server 127.0.0.1:4587 --botnet vDLceacXUkGyPVMOZuf2Hg==
直接浏览器访问,会正确显示 baidu 的页面:
Anywhere.Frp tunnel --binding 127.0.0.1:4588:www.baidu.com:443 --server 127.0.0.1:4587 --botnet vDLceacXUkGyPVMOZuf2Hg== --ssl-off-loading --keep-http-host
不指定 --keep-http-host 时,再访问,会报 403 错误,因为这时候的 http_host 是 127.0.0.1:
Anywhere.Frp tunnel --binding 127.0.0.1:4588:www.baidu.com:443 --server 127.0.0.1:4587 --botnet vDLceacXUkGyPVMOZuf2Hg== --ssl-off-loading
测试1:使用本地 11120 端口,访问百度 443 端口(一定需要指定 --keep-http-host)
Anywhere.Frp tunnel --binding 127.0.0.1:11120:www.baidu.com:443 --ssl-off-loading --keep-http-host
测试2:使用本地 11120 端口,访问 80 端口(去掉 --ssl-off-loading)
Anywhere.Frp tunnel --binding 127.0.0.1:11200:www.ucms.cn:80 --keep-http-host
测试3:将服务器本地 84 端口,映射到被穿透机 ACE 的 81 端口
Anywhere.Frp tunnel
--binding 0.0.0.0:84:127.0.0.1:81 (0.0.0.0:84 对外公开 84 端口)
--server 127.0.0.1:4587
--botnet uYRc/PM+b0OffbfXExgf2A==
--keep-http-host
测试4:通过节点,在本机4588端口,访问百度
Anywhere.Frp tunnel
--binding 127.0.0.1:4588:www.baidu.com:443
--server 122.114.78.190:4587
--botnet OyKTLkLjLUeR5N4N+ZWrFg==
--authenticate-as nuc
--ssl-off-loading
--keep-http-host