frps搭建自己的內網穿透服務器


frps搭建自己的內網穿透服務器
開發過程中,很多時候我們需要用到內網穿透,將自己的服務器映射到外網,下面說一下怎么用frps搭建自己的內網穿透服務器
frps Github地址 里面有中文文檔,大家可以參考

服務器搭建
服務器搭建
服務器是阿里雲ECS CenterOS CentOS 7.4 64位
下載frps服務器文件: 下載地址
選擇frp_0.21.0_linux_amd64.tar.gz,如果你是其他操作系統,請自行選擇
下載完之后,傳到ECS上,然后解壓,編輯frps.ini配置文件
[common]
# 服務器端端口
bind_port = 7000
# 客戶端連接憑證
privilege_token = fxl421125
# 最大連接數
max_pool_count = 5
# 客戶端映射的端口
vhost_http_port = 80
# 服務器看板的訪問端口
dashboard_port = 7500
# 服務器看板賬戶
dashboard_user = admin
dashboard_pwd = fxl123
1
2
3
4
5
6
7
8
9
10
11
12
13
14
設置完以上配置,保存退出,然后啟動服務器

./frps -c ./frps.ini
1
啟動之后查看日志, 提示Start frps success基本上就啟動成功

2018/09/04 11:02:49 [I] [service.go:130] frps tcp listen on 0.0.0.0:7000
2018/09/04 11:02:49 [I] [service.go:172] http service listen on 0.0.0.0:8080
2018/09/04 11:02:49 [I] [root.go:207] Start frps success

客戶端搭建
客戶端是通常是windows
下載frps客戶端文件: 下載地址
選擇frp_0.21.0_windows_amd64.zip 64位文件
然后解壓,配置frpc.ini文件,配置如下:

[common]
# 服務器地址
server_addr = 59.110.161.180
# 服務器端口
server_port = 7000
# 服務器連接憑證
privilege_token = fxl123

[web]
privilege_mode = true
remote_port = 6000
type = http
local_ip = 127.0.0.1
# 本地映射的端口
local_port = 80
use_gzip = true
# 綁定域名 域名需要配置好解析,解析到服務器
custom_domains = manager.fanxl.cn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
命令行啟動客戶端

frpc.exe -c frpc.ini
F:\Program Files\frp_0.21.0_windows_amd64>frpc.exe -c frpc.ini
2018/09/04 11:39:09 [I] [proxy_manager.go:300] proxy removed: []
2018/09/04 11:39:09 [I] [proxy_manager.go:310] proxy added: [web]
2018/09/04 11:39:09 [I] [proxy_manager.go:333] visitor removed: []
2018/09/04 11:39:09 [I] [proxy_manager.go:342] visitor added: []
2018/09/04 11:39:09 [I] [control.go:246] [883f61e2422ed3f3] login to server success, get run id [883f61e2422ed3f3], server udp port [0]
2018/09/04 11:39:09 [I] [control.go:169] [883f61e2422ed3f3] [web] start proxy success

看到如下信息 start proxy success 說明連接成功,此時可以通過7500端口訪問服務器的控制面板頁面,查看連接情況
客戶端可以新建一個start.bat文件,把啟動命令放在里面,這樣每次直接運行bat文件即可

服務器服務后台運行及自動啟動
使用systemd配置開機自啟,適用於 centos7 Ubuntu 16 或 debian 8。

vi /etc/systemd/system/frps.service 新建此文件,並寫入以下內容:

[Unit]

Description=frps daemon

After=syslog.target network.target

Wants=network.target

[Service]

Type=simple

ExecStart=/home/developer/frp_0.21.0_linux_amd64/frps -c /home/developer/frp_0.21.0_linux_amd64/frps.ini

Restart= always

RestartSec=1min

[Install]

WantedBy=multi-user.target
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
啟動並設為開機自啟。

systemctl start frps //啟動

systemctl status frps //狀態查詢

systemctl enable frps //開機啟動

補充一下:

ExecStart=/home/developer/frp_0.21.0_linux_amd64/frps.ini

ExecStart=后面這個是frps文件和配置文件
————————————————
版權聲明:本文為CSDN博主「fanxl12」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/fanxl10/article/details/82381176


免責聲明!

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



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