FRP實現內網穿透


一、准備

  • 公網服務器
  • 內網服務器(自己本地服務器)

二、安裝frp服務端

2.1 公網服務器執行下面四條命令

# apt 更新
apt-get update

# 下載frps服務端腳本
wget --no-check-certificate https://raw.githubusercontent.com/clangcn/onekey-install-shell/master/frps/install-frps.sh -O ./install-frps.sh

# 修改腳本權限
chmod 700 ./install-frps.sh

# 執行腳本安裝
./install-frps.sh install

2.2之后會讓你輸一些參數,直接一路回車默認值就可以了

==============================================
You Server IP      : 45.*******.194
Bind port          : 5443
KCP support        : true
vhost http port    : 80
vhost https port   : 443
Dashboard port     : 6443
token              : WK*******tDGI
tcp_mux            : true
Max Pool count     : 50
Log level          : info
Log max days       : 3
Log file           : enable
==============================================
frps Dashboard     : http://45.*******.194:6443/
Dashboard user     : ******
Dashboard password : ******
==============================================

2.3 瀏覽器訪問控制面板、安裝成功。

img

三、安裝frp客戶端

根據自己本地操作系統選擇下載客戶端 https://github.com/fatedier/frp/releases/

減壓找到配置文件 frpc.ini

# 我的配置
# ./frpc -c ./frpc.ini
[common]
server_addr = 47.93.21.194
server_port = 5443
token = WKMRk7J3adu9tDGI

[web]
type = http
local_ip = 127.0.0.1
local_port = 80
# IP解析
custom_domains = 47.******.194
# 域名解析
# custom_domains = www.xxx.com

四、啟動服務

4.1 首先啟動本地服務器nginx、apache或者tomcat,確保 local_ip 127.0.0.1能夠瀏覽器訪問

img

127.0.0.1

4.2MAC(其他系統參考 frp github)下執行 ./frpc -c ./frpc.ini,驗證外網ip訪問本地服務器。

img

47.******.194

4.3 如果要實現域名訪問內網,只需要域名解析服務端公網IP,服務端的服務器(nginx、apache或者tomcat)配置一下虛擬主機就可以了。


免責聲明!

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



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