1

生活记录+电脑技术:今天搭建成功了frp服务,可以用外网访问内网网站了

 1 year ago
source link: https://www.taholab.com/25181
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.

今天用frp工具搭建了内网穿透服务,可以在外网访问内网网站了。

1.我想在任何地方访问家里的服务器的文件,

2.我想在博客中调用内网的大文件,这样的话,对于这些大文件,就可以存放在内网,而不需要上传到网站服务器,节省服务器空间。

3.我想在任何地方都可以维护家里的网络环境

使用frp工具,服务端放在阿里云服务器里,客户端运行在exsi虚拟机下的centos里或者windows里,这里只需要有一处运行即可。

服务端配置:

将 frps.ini 文件修改为如下内容

[common]
bind_port = 5443
vhost_http_port = 808
vhost_https_port = 909
dashboard_user = admin
dashboard_pwd = admin
token=yourpassword

这里的5443是frp服务端口,808是http服务端口,909是https服务端口。之所以这样做,是因为我的服务器本身用了宝塔面板搭建了网站,因此为了错开80端口和443端口进行了这样的设置。

以上端口需要在宝塔面板中打开防火墙放行,也需要在阿里云管理面板中放行。

然后做域名解析,将需要的域名A记录解析到阿里云服务器上。比如把nas.abc.com解析到了服务器上。

在宝塔面板中新建网站,输入刚才解析的域名nas.abc.com,建立的时候只需要修改一个地方,即PHP版本处,修改为“静态”。然后在“反向代理”处进行修改,对于访问http的话,修改为 “http://127.0.0.1:808”,访问https的话修改为“https://127.0.0.1:909”。

服务端配置完毕。

SSH进入服务器,输入

./frps -c frps.ini

就会启动服务。

客户端配置:

[common]
server_addr = 替换为你的服务器IP地址
server_port = 5443
tls_enable = true
token=yourpassword
[Openwrt]
type = http
local_ip = 192.168.5.1
local_port = 80
remote_port = 808
custom_domains = openwrt.abc.com
[EXSI]
type = https
local_ip = 192.168.5.200
local_port = 80
remote_port = 909
custom_domains = exsi.abc.com
[NAS]
type = http
local_ip = 192.168.5.189
local_port = 5000
remote_port = 808
custom_domains = nas.abc.com
[weilitongbu]
type = http
local_ip = 192.168.5.189
local_port = 8886
remote_port = 808
custom_domains = weili.abc.com
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000

以上的内网IP地址、端口和域名相应的替换为你的即可。

./frpc -c frpc.ini

无误的话就会建立连接。举例如下:

如果在浏览器访问 http://nas.abc.com:808,则会打开内网的http://192.168.5.189:5000。

所有数据基本上都是从服务器转发的,因此会受限于服务器的带宽以及流量上限。我的服务器一个月2000Gb浏览,30Mbps带宽,勉强够用。

已经可以访问NAS了


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK