内网穿透FRP

内网穿透FRP

之前花了几百块钱买了个低功耗的工控机,刷了群晖系统,最开始电信网申请了公网IP,传递文件速度杠杠的。但是好景不长,由于宽带价格高于市场价一倍,老婆想省钱,换了联通的宽带,公网IP没了。 尝试过找运营商搞到路由器管理员密码 ,换桥接后发现依然在一个大的局域网里面 。

最开始直接用花生壳的免费内网穿透,结果发现不能自定义域名,且没有子域名解析,最最不能忍的是带宽!!3M的文件传了几分钟!

正好腾讯云lighthouse 周年庆 ,99元领券89元一年到手

image-20240928193229519

现状

内网nas需要映射的服务 有gitlab服务, jenkins服务,一个博客服务,还有个静态资源文档地址,包括群晖自己的登录网站。

FRP穿透操作步骤

本地nas工控机部署FRPC客户端 腾讯云服务器部署FRPS服务端。 阿里云的域名泛解析到腾讯云, 请求访问域名,解析到腾讯云,通过腾讯云服务器中转到本地nas。

server端

镜像:snowdreamtech/frps:latest 端口 7080–>7080/tcp 7081–>7081/tcp 7500–>7500/tcp 映射:/etc/myconf/frp /etc/frp

frps.init文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[common]
# 监听端口
bind_port = 2025

# 面板端口
dashboard_port = 7500
# 登录面板账号设置
dashboard_user = admin
dashboard_pwd = testpassword
# 设置http及https协议下代理端口(非重要)
vhost_http_port = 7080
vhost_https_port = 7081

# 身份验证
token = testToken

客户端

容器: snowdreamtech/frpc:latest 暴露端口 无 映射; /docker/frp /etc/frp

frpc.toml 文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
[common]
# server_addr为FRPS服务器IP地址
server_addr = 公网ip
# server_port为服务端监听端口,bind_port
server_port = 2025
# 身份验证
token = testtoken

[ssh]
type = tcp
local_ip = 192.168.1.100
local_port = 22
remote_port = 2288

[http_xxxxxxx]
type = http
local_ip = 192.168.1.100
local_port = 80
custom_domains = *.nicetoo.cyou

[https_xxxxxxx]
type = http
local_ip = 192.168.1.100
local_port = 443
custom_domains = *.nicetoo.cyou

[jenkins]
type = tcp
local_ip = 192.168.1.100
local_port = 9008
remote_port = 2098

[gitlab]
type = tcp
local_ip = 192.168.1.100
local_port = 9001
remote_port = 2091

[qunhui https]
type = tcp
local_ip = 192.168.1.100
local_port = 5001
remote_port = 5001

[qunhui http]
type = tcp
local_ip = 192.168.1.100
local_port = 5000
remote_port = 5000




启动容器后

启动后访问server端7500 看管理员配置页面。通过serverip:端口 看能否正常访问对应的服务,如果不能正常访问,说明云server到我们的内网主机是通的。剩下的就是通过云服务器上的ngnix 反向代理 实现不同子域名映射到不同的端口

1
2
3
4
5
6
访问

blog.ncietoo.cyou ===> 访问内网博客页面
jenkins.ncietoo.cyou ===> 访问内网jenkins页面
gitlab.ncietoo.cyou ===> 访问内网jenkins页面

Q & A

  1. 如果服务都启动了,但是链路不通,检查下防火墙是否有开启。

  2. 网站dockker容器拉取失败, 请科学上网,这个服务器在新加坡,所以可以当个vps转发,科学上网

  3. 配置文 新版本和旧版本的文件后缀名不一致 最好拉最新的docker 容器 看官方文档配置


内网穿透FRP
https://blog.dayday.cyou/2024/09/28/基于frp内网穿透方案/
作者
godbutton
发布于
2024年9月28日
许可协议