frp 是一個(gè)專注于內(nèi)網(wǎng)穿透的高性能的反向代理應(yīng)用遭庶,支持 TCP承匣、UDP蓖乘、HTTP、HTTPS 等多種協(xié)議韧骗〖问悖可以將內(nèi)網(wǎng)服務(wù)以安全、便捷的方式通過(guò)具有公網(wǎng) IP 節(jié)點(diǎn)的中轉(zhuǎn)暴露到公網(wǎng)袍暴。
frp is a high-performance reverse proxy application focusing on intranet penetration, supporting multiple protocols such as TCP, UDP, HTTP, and HTTPS. Intranet services can be exposed to the public network through a relay with public network IP nodes in a safe and convenient way.
為什么使用 frp 些侍?
Why use frp?
通過(guò)在具有公網(wǎng) IP 的節(jié)點(diǎn)上部署 frp 服務(wù)端,可以輕松地將內(nèi)網(wǎng)服務(wù)穿透到公網(wǎng)政模,同時(shí)提供諸多專業(yè)的功能特性岗宣,這包括:
By deploying the frp server on a node with a public network IP, you can easily penetrate the internal network service to the public network, while providing many professional features, including:
客戶端服務(wù)端通信支持 TCP、KCP 以及 Websocket 等多種協(xié)議淋样。
The client-server communication supports multiple protocols such as TCP, KCP, and Websocket.
采用 TCP 連接流式復(fù)用耗式,在單個(gè)連接間承載更多請(qǐng)求,節(jié)省連接建立時(shí)間趁猴。
Use TCP connection streaming multiplexing to carry more requests between a single connection, saving connection establishment time.
代理組間的負(fù)載均衡刊咳。
Load balancing between proxy groups.
端口復(fù)用,多個(gè)服務(wù)通過(guò)同一個(gè)服務(wù)端端口暴露儡司。
Port reuse, multiple services are exposed through the same server port.
多個(gè)原生支持的客戶端插件(靜態(tài)文件查看娱挨,HTTP、SOCK5 代理等)便于獨(dú)立使用 frp 客戶端完成某些工作捕犬。
Multiple natively supported client plug-ins (static file viewing, HTTP, SOCK5 proxy, etc.) facilitate independent use of frp client to complete certain tasks.
高度擴(kuò)展性的服務(wù)端插件系統(tǒng)跷坝,方便結(jié)合自身需求進(jìn)行功能擴(kuò)展。
The highly extensible server-side plug-in system facilitates functional expansion according to your own needs.
服務(wù)端和客戶端 UI 頁(yè)面或听。
Server and client UI pages.
簡(jiǎn)單來(lái)說(shuō)探孝,frp是一個(gè)反向代理軟件,他的體積小巧功能強(qiáng)大誉裆,講內(nèi)網(wǎng)IP進(jìn)行frp反向代理后顿颅,即可使用代理IP進(jìn)行訪問(wèn)內(nèi)網(wǎng)機(jī)器的服務(wù),例如遠(yuǎn)程桌面足丢,雖然遠(yuǎn)程桌面有第三方軟件來(lái)代替粱腻,例如向日葵庇配,teamviewer,等一些軟件進(jìn)行遠(yuǎn)程绍些,這些軟件都有一些詬病捞慌,向日葵沒(méi)有會(huì)員會(huì)限速,而tv登錄遠(yuǎn)程連接會(huì)比較慢柬批。所以可以考慮到使用內(nèi)網(wǎng)穿透或者反向代理啸澡。
To put it simply, frp is a reverse proxy software, its size is small and powerful, after talking about the intranet IP for frp reverse proxy, you can use the proxy IP to access the services of the intranet machine, such as remote desktop, although remote desktop There are third-party software to replace, such as Sunflower, teamviewer, and other software for remote. These softwares have some criticisms. Sunflower does not have a membership rate limit, and the tv login remote connection will be slow. So you can consider using intranet penetration or reverse proxy.
內(nèi)網(wǎng)穿透可參考:有一個(gè)公網(wǎng)IP地址
Intranet penetration can refer to: there is a public IP address
使用端口進(jìn)行訪問(wèn)時(shí),原理如下
When using the port for access, the principle is as follows
準(zhǔn)備工作:
Ready to work:
1氮帐、首先得有一臺(tái)云服務(wù)器進(jìn)行提供網(wǎng)絡(luò)帶寬嗅虏,frp代理帶寬一般受限于該服務(wù)器帶寬
2、一臺(tái)目標(biāo)機(jī)器上沐,也就是需要反向代理的機(jī)器
1. First, there must be a cloud server to provide network bandwidth, and the frp proxy bandwidth is generally limited by the server bandwidth
2. A target machine, that is, a machine that needs a reverse proxy
云服務(wù)器端配置:
Cloud server configuration:
使用命令查看云服務(wù)器的架構(gòu)皮服,一般云服務(wù)器架構(gòu)為x86
Use commands to view the architecture of the cloud server, the general cloud server architecture is x86
[root@cby ~]# arch x86_64
使用命令下載frp軟件包
Use command to download frp package
[root@cby ~]# wget https://github.com/fatedier/frp/releases/download/v0.35.1/frp_0.35.1_linux_amd64.tar.gz
下載完成后進(jìn)行解壓
Unzip after downloading
[root@cby ~]# tar -xvf frp_0.35.1_linux_amd64.tar.gz
frp_0.35.1_linux_amd64/
frp_0.35.1_linux_amd64/frps.ini
frp_0.35.1_linux_amd64/frps_full.ini
frp_0.35.1_linux_amd64/systemd/
frp_0.35.1_linux_amd64/systemd/frpc@.service
frp_0.35.1_linux_amd64/systemd/frpc.service
frp_0.35.1_linux_amd64/systemd/frps.service
frp_0.35.1_linux_amd64/systemd/frps@.service
frp_0.35.1_linux_amd64/frpc
frp_0.35.1_linux_amd64/frpc_full.ini
frp_0.35.1_linux_amd64/frps
frp_0.35.1_linux_amd64/frpc.ini
frp_0.35.1_linux_amd64/LICENSE
修改文件夾名稱
Modify folder name
[root@cby ~]# cp -r frp_0.35.1_linux_amd64 frp
[root@cby ~]#
[root@cby ~]# ll
total 8508
drwxr-xr-x 3 root? root? ? 4096 Feb 19 22:13 frp
drwxr-xr-x 3 mysql? 116? ? 4096 Jan 25 16:25 frp_0.35.1_linux_amd64
-rw-r--r-- 1 root? root 8695632 Jan 25 16:25 frp_0.35.1_linux_amd64.tar.gz
只需要關(guān)注如下幾個(gè)文件
Only need to pay attention to the following files
frps
frps.ini
frpc
frpc.ini
frps 、frps.ini 這倆個(gè)文件是服務(wù)端的配置文件和啟動(dòng)程序
frpc参咙、frpc.ini 這倆個(gè)文件是客戶端的配置文件和啟動(dòng)程序
The two files frps and frps.ini are the configuration files and startup programs of the server
The two files frpc and frpc.ini are the configuration files and startup programs of the client
編輯并添加以下內(nèi)容
Edit and add the following
[root@cby frp]# vim frps.ini
[root@cby frp]# cat frps.ini
[common]
bind_port = 7000
dashboard_port = 7500
token = 12345678
dashboard_user = admin
dashboard_pwd = admin
vhost_http_port = 10080
vhost_https_port = 10443
解釋如下
Explain as follows
“bind_port”表示用于客戶端和服務(wù)端連接的端口龄广,這個(gè)端口號(hào)我們之后在配置客戶端的時(shí)候要用到。
“dashboard_port”是服務(wù)端儀表板的端口蕴侧,若使用7500端口择同,在配置完成服務(wù)啟動(dòng)后可以通過(guò)瀏覽器訪問(wèn) x.x.x.x:7500 (其中x.x.x.x為VPS的IP)查看frp服務(wù)運(yùn)行信息。
“token”是用于客戶端和服務(wù)端連接的口令戈盈,請(qǐng)自行設(shè)置并記錄奠衔,稍后會(huì)用到。
“dashboard_user”和“dashboard_pwd”表示打開儀表板頁(yè)面登錄的用戶名和密碼塘娶,自行設(shè)置即可。
“vhost_http_port”和“vhost_https_port”用于反向代理HTTP主機(jī)時(shí)使用痊夭,本文不涉及HTTP協(xié)議刁岸,因而照抄或者刪除這兩條均可。
文件修改完成后即可使用該命令進(jìn)行啟動(dòng)
After the file is modified, you can use this command to start
[root@cby frp]# ./frps -c frps.ini
2021/02/19 22:18:45 [I] [root.go:108] frps uses config file: frps.ini
2021/02/19 22:18:45 [I] [service.go:190] frps tcp listen on 0.0.0.0:7000
2021/02/19 22:18:45 [I] [service.go:232] http service listen on 0.0.0.0:10080
2021/02/19 22:18:45 [I] [service.go:253] https service listen on 0.0.0.0:10443
2021/02/19 22:18:45 [I] [service.go:289] Dashboard listen on 0.0.0.0:7500
2021/02/19 22:18:45 [I] [root.go:217] frps started successfully
若使用云服務(wù)器記得需要放行所需端口
If you use cloud server, remember to release the required port
此時(shí)訪問(wèn) x.x.x.x:7500 并使用自己設(shè)置的用戶名密碼登錄她我,即可看到儀表板界面
At this time, visit x.x.x.x:7500 and log in with the username and password you set, you can see the dashboard interface
把服務(wù)在后臺(tái)運(yùn)行即可
Just run the service in the background
[root@cby frp]# nohup ./frps -c frps.ini &
[1] 4852
[root@cby frp]# jobs
[1]+? Running? ? ? ? ? ? ? ? nohup ./frps -c frps.ini &
客戶端配置
Client configuration
Windows系統(tǒng)下即可下載這個(gè):
You can download this under Windows system:
https://github.com/fatedier/frp/releases/download/v0.35.1/frp_0.35.1_windows_amd64.zip
frpc.ini文件內(nèi)容為
The content of the frpc.ini file is
[common]
server_addr = 123.56.237.11
server_port = 7000
token = 12345678
[rdp]
type = tcp
local_ip = 127.0.0.1? ?
local_port = 3389
remote_port = 7001?
[smb]
type = tcp
local_ip = 127.0.0.1
local_port = 445
remote_port = 7002
含義解釋
Meaning interpretation
“server_addr”為服務(wù)端IP地址虹曙,填入即可。 “server_port”為服務(wù)器端口番舆,填入你設(shè)置的端口號(hào)即可酝碳,如果未改變就是7000 “token”是你在服務(wù)器上設(shè)置的連接口令,原樣填入即可恨狈。
自定義規(guī)則如下
The custom rules are as follows
“[xxx]”表示一個(gè)規(guī)則名稱疏哗,自己定義,便于查詢即可禾怠。 “type”表示轉(zhuǎn)發(fā)的協(xié)議類型返奉,有TCP和UDP等選項(xiàng)可以選擇贝搁,如有需要請(qǐng)自行查詢frp手冊(cè)。 “l(fā)ocal_port”是本地應(yīng)用的端口號(hào)芽偏,按照實(shí)際應(yīng)用工作在本機(jī)的端口號(hào)填寫即可雷逆。 “remote_port”是該條規(guī)則在服務(wù)端開放的端口號(hào),自己填寫并記錄即可污尉。
客戶端的啟動(dòng)是需要使用命令行進(jìn)行啟動(dòng)的膀哲, 無(wú)法使用雙擊EXE進(jìn)行啟動(dòng)。
The startup of the client needs to use the command line to start, it cannot be started by double-clicking the EXE.
C:\Users\Administrator>cd c:\
c:\>cd frp
c:\frp>frpc.exe -c frpc.ini
2021/02/19 22:35:49 [I] [service.go:290] [bf2998700defd7c5] login to server success, get run id [bf2998700defd7c5], server udp port [0]
2021/02/19 22:35:49 [I] [proxy_manager.go:144] [bf2998700defd7c5] proxy added: [rdp smb]
2021/02/19 22:35:49 [I] [control.go:180] [bf2998700defd7c5] [rdp] start proxy success
2021/02/19 22:35:49 [I] [control.go:180] [bf2998700defd7c5] [smb] start proxy success
配置完成后即可在面板上看到該規(guī)則
After the configuration is complete, you can see the rule on the panel
同時(shí)使用遠(yuǎn)程連接工具使用IP或者域名即可進(jìn)行連接
但是Windows客戶端的cmd是無(wú)法關(guān)閉的被碗,關(guān)閉后就無(wú)法使用了等太,所以需要設(shè)置開機(jī)自啟,使用bat腳本即可做到
At the same time, use the remote connection tool to connect using IP or domain name
However, the cmd of the Windows client cannot be closed, and it cannot be used after it is closed, so you need to set the boot to start automatically, and you can use the bat script
@echo off
if "%1" == "h" goto begin
mshta vbscript:createobject("wscript.shell").run("""%~nx0"" h",0)(window.close)&&exit
:begin
REM
cd C:\frp
frpc.exe -c frpc.ini
exit
寫完之后直接把文件扔到Windows的開機(jī)啟動(dòng)文件夾即可
After writing, throw the file directly into the Windows startup folder.