11

威联通搭建Frp实现内网穿透

 3 years ago
source link: http://blog.devwiki.net/2022/03/21/qnap-install-frp.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

由于联通不知道什么原因,把整个省的个人动态公网IP都给停止了,所以需要找别的方式来访问我的NAS,.

在网上搜索得知,有以下几种方式:

  • 使用花生壳或者别的ddns服务
  • 使用开源的frp方案

查询了下 花生壳的服务收费如下:

368元一年不算贵, 但是这个速率才 1Mbps,换算下来才 128K/s, 实在是太慢了.

而Frp需要自己配置Server端, 也有第三方开发者提供免费的服务端, 如: Free FRP 免费 FRP 内网穿透

而目前国内的服务器价格也比较划算, 比如: 【腾讯云】爆款2核2G云服务器首年40元,企业首购最高获赠300元京东卡

我购买的是上图的 2核4G 的套餐, 6Mbps 带宽算下来 0.75M/s, 日常使用还算可以了, 同步大文件可以到家以后 使用局域网同步.

2. 配置Frp Server端

根据官网的说明, 修改 frps.ini 文件如下:

[common]
bind_port = 443
token=[自己设置一个Token]

vhost_http_port = 80
vhost_https_port = 443

# 服务端 Dashboard 
dashboard_port = 7400
# dashboard 用户名密码,可选,默认为空
dashboard_user = admin
dashboard_pwd = admin

# TCP 多路复用 
tcp_mux = false
# 连接池上限
max_pool_count = 5

然后根据说明启动服务端:

./frps -c ./frps.ini

看到命令行输出如下,则说明服务器端启动成功:

C:\Users\Administrator\Downloads\frp_0.39.1_windows_amd64>frps.exe -c frps.ini
2022/03/21 20:43:09 [I] [root.go:200] frps uses config file: frps.ini
2022/03/21 20:43:09 [I] [service.go:193] frps tcp listen on 0.0.0.0:443
2022/03/21 20:43:09 [I] [service.go:236] http service listen on 0.0.0.0:80
2022/03/21 20:43:09 [I] [service.go:292] Dashboard listen on 0.0.0.0:8081
2022/03/21 20:43:09 [I] [root.go:209] frps started successfully

3. 安装客户端

打开威联通的 ContainerStation, 在 Create 界面输入: stilleshan/frpc,然后搜索如下:

点击 install 按钮, 选择最新版

然后点击 高级设置(Advanced Setting)

网络设置设置位 host:

然后 共享文件夹部分设置如下:

其中NAS目录如下:

然后点击 create, 等待创建完成

4. 配置Frp客户端

打开NAS上刚才配置的目录, 并上传Frp项目文件, 编辑 frpc.ini文件:

[common]
server_addr = 服务器的ip
server_port = 服务器的 bind_port
token=服务器的token

# Admin UI 管理界面配置
admin_addr = 127.0.0.1
admin_port = 7400
admin_user = admin
admin_pwd = admin

# TCP 多路复用 
tcp_mux = false

# 连接池上限
max_pool_count = 1

[nas]
type = http
local_ip=127.0.0.1
local_port=80
custom_domains = 你的nas的域名

[nas_https]
type = https
custom_domains = 你的nas的域名
plugin = https2http
plugin_local_addr = 127.0.0.1:80
# HTTPS 证书相关的配置
# 在上图的 ssl 文件夹存放 你的证书 key 和 crt 或者 key 和 pem文件
plugin_key_path = /frp/ssl/nas.key
plugin_crt_path = /frp/ssl/nas.crt
plugin_host_header_rewrite = 127.0.0.1
plugin_header_X-From-Where = frp

启动 frpc 查看结果如下则正常:

2022/03/21 20:43:10 [I] [service.go:175] [5f8e02cd963489f2] try to reconnect to server...
2022/03/21 20:43:10 [I] [service.go:327] [5f8e02cd963489f2] login to server success, get run id [5f8e02cd963489f2], server udp port [0]
2022/03/21 20:43:10 [I] [proxy_manager.go:144] [5f8e02cd963489f2] proxy added: [nas nas_https]
2022/03/21 20:43:10 [I] [control.go:181] [5f8e02cd963489f2] [nas] start proxy success
2022/03/21 20:43:10 [I] [control.go:181] [5f8e02cd963489f2] [nas_https] start proxy success

然后输入你刚设置的域名测试结果:

此处特别感谢 思有云 - IOIOX - 个人博客 提供的 Dockers镜像以及技术支持.

Stille 的博客: 思有云 - IOIOX - 个人博客

使用的Docker 镜像地址: Docker Hub

如有关于镜像的问题,请在GitHub上添加 issue: stilleshan/frpc


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK