需要公網IP服務器用來做轉發機,經過frps服務穿透到無公網IP的服務器,達到隨處訪問的目的
一 公網服務器搭建frps服務
frps服務各種版本地址: https://github.com/fatedier/frp/releases
我選的是frp_0.29.0_linux_amd64版本
tar -xvf frp_0.29.0_linux_amd64.tar.gz 解壓文件
進入文件,修改frps.ini 配置文件,注意 rfps爲服務端配置,frp爲客戶端配置
[common]
# 服務器端端口
bind_port = 7000
# 客戶端連接憑證
privilege_token = 123456
# 最大連接數
max_pool_count = 5
# 客戶端映射的端口
vhost_http_port = 80
vhost_https_port = 443
# 服務器看板的訪問端口
dashboard_port = 7500
# 服務器看板賬戶
dashboard_user = admin
dashboard_pwd = password
啓動服務
或者後臺啓動 nohup /frps/frp_0.29.0_linux_amd64/frps -c /frps/frp_0.29.0_linux_amd64/frps.ini &
製作服務後臺運行
在 /etc/systemd/system 目錄下創建 frps.service
內容爲:
[Unit]
Description=frps
After=network.target
[Service]
TimeoutStartSec=30
ExecStart=/frps/frp_0.29.0_linux_amd64/frps -c /frps/frp_0.29.0_linux_amd64/frps.ini
ExecStop=/bin/kill $MAINPID
[Install]
WantedBy=multi-user.target
啓動服務 systemctl start frps
設置開機啓動 systemctl enable frps
查看狀態 systemctl status frps
二 客戶端配置
同樣下載文件解壓
這次配置的是 frpc.ini
[common]
# 服務器地址
server_addr = ip
# 服務器端口
server_port = 7000
# 服務器連接憑證
privilege_token = password
[web]
privilege_mode = true
remote_port = 6000
type = http
local_ip = 127.0.0.1
# 本地映射的端口
local_port = 80
use_gzip = true