FRP(Fast Reverse Proxy)是一個高性能的反向代理應(yīng)用,可以幫助你輕松地實現(xiàn)內(nèi)網(wǎng)穿透,從而可以在不同的網(wǎng)絡(luò)環(huán)境中訪問內(nèi)網(wǎng)服務(wù)器。網(wǎng)上frp配置大多是配置ini文件,而frp3.5版本后就不支持ini了,必須采用toml配置了,以下是一個完整案例
環(huán)境:2臺服務(wù)器
A:阿里云服務(wù)器(有公網(wǎng)地址)如:32.96.29.82
B:局域網(wǎng)服務(wù)器(一般是Mobox服務(wù)部署服務(wù)器) 如:192.168.0.66
(服務(wù)器A 公網(wǎng))
1、拷貝 frp_0.58.1_windows_amd64.zip 到服務(wù)器A
2、解壓后(比如 解壓到 frp_0.58.1_windows_amd64 目錄),這批解壓的文件非常可能被Windows自帶防火墻殺掉(它認為是病毒)
所以,這個解壓的目錄,在windows的自帶防火墻(windows defender)內(nèi)最好設(shè)置忽略。 否則非常可能被刪除
(win+r)進入 ,windows 設(shè)置,找到 windows defender ,找到“排除” 將這個目前排除掉
3、進入 frp_0.58.1_windows_amd64 ,打開frps.toml
編寫:
bindPort =7000 (這個端口可以根據(jù)需要自己改)
vhostHTTPPort =7005 (根據(jù)需要進行修改)(若是 https 要改成:vhostHTTPSPort)
auth.method = “token”
auth.token = “123456”? ? ?(密碼)
4、當前目錄下編寫 StartS.bat 文件,內(nèi)容
@echo off
:home
frps -c frps.toml
5、運行StartS.bat
(服務(wù)器B 局域網(wǎng),部署了 Mobox的服務(wù)器)
1、拷貝 frp_0.58.1_windows_amd64.zip 到服務(wù)器A
2、解壓后(比如 解壓到 frp_0.58.1_windows_amd64 目錄),這批解壓的文件非常可能被Windows自帶防火墻殺掉(它認為是病毒)
所以,這個解壓的目錄,在windows的自帶防火墻(windows defender)內(nèi)最好設(shè)置忽略。 否則非常可能被刪除
(win+r)進入 ,windows 設(shè)置,找到 windows defender ,找到“排除” 將這個目前排除掉
3、進入 frp_0.58.1_windows_amd64 ,打開frpc.toml
內(nèi)容:
serverAddr = 32.96.29.82? ?(這個根據(jù)實際公網(wǎng)IP進行配置)
server_port =7000 (這個可以根據(jù) frps.toml 情況進行修改)
auth.method = “token”
auth.token = “123456”
[proxies] 里面各個mobox3服務(wù)及網(wǎng)站的端口,根據(jù)實際端口進行配置 (目前例子里面7001-7005)
[[proxies]]
name = “wwwSite”
type = “http”
localIP = “127.0.0.1”
localPort = 7110 (本機網(wǎng)站端口)
customDomains = [“39.99.229.82”]? ? ? (最好是域名 ,也可以ip)
[[proxies]]
name = “OrgAPI”
type = “tcp”
localIP = “127.0.0.1”
localPort = 5101
remotePort = 7001
4、編寫當前目錄下的 StartC.bat 文件
@echo off
:home
frpc -c frpc.toml
5、運行StartC.bat
(關(guān)于 服務(wù)器A 公網(wǎng)這臺服務(wù)器 所需要打開的端口)
根據(jù)目前配置的情況,需要打開 7000-7005
這里7005比較特殊; 是frps.toml 登錄的http 端口
我們需要 32.96.29.82:5705/mobox 來登錄內(nèi)網(wǎng)部署的mobox