1. 程式人生 > >如何用frp進行來無影去無蹤

如何用frp進行來無影去無蹤

準備工作 和 注意事項:

1.frp 下載地址  https://github.com/fatedier/frp/releases

2. 需要給有公網ip 的服務端伺服器 和 本地客戶端伺服器 各放一份這個程式碼

3. 將 www.yourdomain.com 的域名 A 記錄解析到 IP x.x.x.x,如果伺服器已經有對應的域名,也可以將 CNAME 記錄解析到伺服器原先的域名。

4. 伺服器端只需要修改  frps.ini  客戶端只需要修改 frpc.ini

開始搭建:

a. 服務端伺服器(有公網ip)

[[email protected] frp]#  wget https://github.com/fatedier/frp/releases/download/v0.20.0/frp_0.20.0_linux_amd64.tar.gz

[[email protected] frp]#  tar -zxvf frp_0.20.0_linux_amd64.tar.gz

[[email protected] frp]#  mv frp_0.20.0_linux_amd64 frp

[[email protected] frp]#  cd frp

[[email protected] frp]#  vim frps.ini       //這裡的frps  代表 frp server 伺服器端的 修改為以下內容然後儲存

[common]
bind_port = 7000
vhost_http_port = 8080

[

[email protected] frp]# nohup ./frps -c ./frps.ini &    //啟動frps  並在後臺執行

---以上 伺服器端搭建完畢 ---

b.客戶端伺服器(本地的虛擬機器 我的是centos系統)

[[email protected] frp]#  wget https://github.com/fatedier/frp/releases/download/v0.20.0/frp_0.20.0_linux_amd64.tar.gz

[[email protected] frp]#  tar -zxvf frp_0.20.0_linux_amd64.tar.gz

[[email protected] frp]#  mv frp_0.20.0_linux_amd64 frp

[[email protected] frp]#  cd frp

[[email protected] frp]#  vim frpc.ini       //這裡的frpc  代表 frp client 客戶器端的 修改為以下內容然後儲存

[common]
server_addr = 45.76.173.***   <遠端frp伺服器ip> <你的伺服器端 公網ip>
server_port = 7000 <遠端frp伺服器埠> < 就是伺服器端配置frps.ini的 bind_port = 7000 >

[http]
type = http <協議型別>
local_ip = 192.168.1.132 <本地伺服器的ip地址>
local_port = 8888  <本地埠號>
remote_port = 8080 <遠端frp伺服器的http服務埠號 > < 就是伺服器端配置frps.ini的 vhost_http_port = 8080 >
custom_domains = www.yourdomain.com <配置的域名>

[[email protected] frp]# nohup ./frpc -c ./frpc.ini &    //啟動frpc  並在後臺執行

---以上 客戶端搭建完畢 ---

最後:

通過瀏覽器訪問 http://www.yourdomain.com:8080 即可訪問到處於內網機器上的 web 服務。