frp對http協議應用


前言

frp是一個開源的項目, 可用於內網穿透的高性能的反向代理應用,支持 tcp, udp 協議,為 http 和 https 應用協議提供了額外的能力,且嘗試性支持了點對點穿透。

github地址:https://github.com/fatedier/frp

此處對http的應用做一個簡單的記錄,使用frp-v0.20.0版本進行介紹

 

1.軟件下載地址

https://github.com/fatedier/frp/releases?after=v0.25.1

2.服務端配置

linux下配置,需要有一個公網的服務器,假如公網ip為 xxx.xxx.xxx.xxx

下載軟件:frp_0.20.0_linux_amd64.tar.gz

解壓:tar -zxvf frp_0.20.0_linux_amd64.tar.gz

cd frp_0.20.0_linux_amd64

啟動服務端: 

./frps --bind_port=7000 --vhost_http_port=8080

其中:

  --bind_port 為frp服務端口

  --vhost_http_port為http服務端口

3.客戶端配置

3.1 windows下配置

下載軟件:frp_0.20.0_windows_amd64.zip

解壓:進入frp_0.20.0_windows_amd64目錄

編輯:

frpc.ini 文件

[common]
server_addr = xxx.xxx.xxx.xxx
server_port = 7000

[web01]
type = http
local_port = 7758
custom_domains = xxx.xxx.xxx.xxx

說明:

  server_addr : frp的服務地址
  server_port : frp的服務端口

  web01:代理名稱,隨意命名
  type : 協議類型,此處為http
  local_port : 代理的本地端口
  custom_domains : 代理的地址,可以使用域名

3.2 啟動客戶端

打開cmd 命令窗口

執行:frpc.exe -c frpc.ini

3.3 訪問方法

使用custom_domains 指定的地址或者域名,端口為服務端的--vhost_http_port 指定的端口,此處為8080, 訪問后就相當於訪問到了本地的端口 7758
此處為: xxx.xxx.xxx.xxx:8080
代理方式相當於: xxx.xxx.xxx.xxx:8080 --> 127.0.0.1:7758

 4.建立多個反向代理

這里的服務端和客戶端是一對一的,所以需要重新建立服務端,指定不同的frp端口和http的端口

4.1 服務端

./frps --bind_port=7001 --vhost_http_port=8081

4.2 客戶端

從frpc.ini復制一個frpc1.ini,內容如下:

[common]
server_addr = xxx.xxx.xxx.xxx
server_port = 7001

[web02]
type = http
local_port = 7759
custom_domains = xxx.xxx.xxx.xxx

啟動:frpc.exe -c frpc1.ini

訪問:xxx.xxx.xxx.xxx:8081

代理方式相當於: xxx.xxx.xxx.xxx:8081 --> 127.0.0.1:7759


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM