1.創(chuàng)建配置文件目錄
cd /home目錄
mkdir frp
最后的目錄結(jié)構(gòu):
2.創(chuàng)建服務(wù)端配置文件
vi frps.ini
[common]
bind_port = 17000
token = myToken
vhost_http_port = 10080
vhost_https_port = 10443
dashboard_port = 17500
dashboard_user = admin
dashboard_pwd = admin
tcp_mux = true
max_pool_count = 10
3.創(chuàng)建服務(wù)端yml文件
vi frps-docker-compose.yml
version: '3'
services:
frps:
image: snowdreamtech/frps
ports:
- "17000:17000"
- "27500:17500"
- "10022:10022" #用于ssh連接
- "10080:10080" #用于開(kāi)放給外網(wǎng)訪問(wèn)
# 更多端口根據(jù)實(shí)際需求增加
volumes:
- ./frps.ini:/etc/frp/frps.ini container_name: frps
4.啟動(dòng)服務(wù)端
docker-compose -f frps-docker-compose.yml up 注意:開(kāi)啟后臺(tái)運(yùn)行-d
5.創(chuàng)建客戶(hù)端配置文件
vifrpc.ini
[common]
#服務(wù)器ip
server_addr = x.x.x.x
server_port = 17000
token = myToken
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 10022
use_encryption = true
use_compression = true
[pi.mydomain.com]
type = http
local_port = 80
custom_domains = pi.mydomain.com
6.創(chuàng)建客戶(hù)端yml文件
vi frpc-docker-compose.yml
version: '3'
services:
frpc:
image: cloverzrg/frpc-docker
volumes:
- ./frpc.ini:/conf/frpc.ini
container_name: frpc
network_mode: host
8.啟動(dòng)客戶(hù)端
docker-compose -f frpc-docker-compose.yml up -d
- 訪問(wèn)域名http://pi.mydomain.com:10080,可以正常訪問(wèn)網(wǎng)頁(yè)(前提是客戶(hù)端所在機(jī)器啟動(dòng)http服務(wù)器,并監(jiān)聽(tīng)80端口);,注意先將 pi.mydomain.com的域名 A 記錄解析到 IP x.x.x.x,如果服務(wù)器已經(jīng)有對(duì)應(yīng)的域名,也可以將 CNAME 記錄解析到服務(wù)器原先的域名。
- 通過(guò)ssh -p 10022 用戶(hù)名@x.x.x.x遠(yuǎn)程連接;
- 訪問(wèn)http:x.x.x.x:27500,可以看到儀表盤(pán),里面顯示了各個(gè)客戶(hù)端的連接情況.
參考:https://liyangweb.com/service/358.html
frp中文文檔:https://www.cnblogs.com/yanglang/p/12035934.html
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。