目录什么是 frp为什么使用 frp安装使用使用场景统一的服务端配置ssh 连接内网服务器暴露内网 Http 服务tcp 类型HTTP 类型静态文件下载服务本文将分享一个很好用的内网
本文将分享一个很好用的内网穿透工具 frp,以及一些具体的使用场景。
frp 是一个专注于内网穿透的高性能的反向代理应用,支持 TCP、UDP、HTTP、https 等多种协议。可以将内网服务以安全、便捷的方式通过具有公网 IP 节点的中转暴露到公网。
通过在具有公网 IP 的节点上部署 frp 服务端,可以轻松地将内网服务穿透到公网,同时提供诸多专业的功能特性,这包括:
可以在 GitHub 的 Release 页面中进行下载:
curl -LO https://github.com/fatedier/frp/releases/download/v0.37.0/frp_0.37.0_linux_amd64.tar.gz
tar zxf frp_0.37.0_linux_amd64.tar.gz
压缩包里包含了客户端和服务端的两个可执行文件,以及对应的配置文件:
> tree -L 1 frp_0.37.0_linux_amd64
frp_0.37.0_linux_amd64
├── frpc # 客户端程序
├── frpc_full.ini # 对应客户端程序的详细配置文件
├── frpc.ini # 对应客户端程序的简单配置文件
├── frps # 服务端程序
├── frps_full.ini # 对应服务端程序的详细配置文件
├── frps.ini # 对应服务端程序的简单配置文件
├── LICENSE
└── systemd
├── frpc.service # 客户端的 systemd 服务配置文件
├── frpc@.service # 客户端的 systemd 模板文件
├── frps.service # 服务端的 systemd 服务配置文件
└── frps@.service # 服务端的 systemd 模板文件
首先,这个工具需要一个公网服务器配置使用,配置文件可以参考详细的配置文件进行编写,后面会讲到自己常用的几个场景下的配置。
先启动服务端:
./frps -c ./frps.ini
再启动客户端:
./frpc -c ./frpc.ini
Tip:如果需要在后台长期运行,可以结合 systemd 或者 supervisor 进行使用。
[common]
bind_port = 9999
authentication_method = token
token = yourtokenhere
vhost_http_port = 10001
vhost_https_port = 10002
配置说明:
下面将都是基于这个服务端配置的一些场景下的客户端配置。
[common]
server_addr = x.x.x.x
server_port = 9999
token = yourtokenhere
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6666
配置说明:
现在,我们就可以通过 SSH 连接内网服务器:
ssh -p 6666 k8scat@x.x.x.x
这种方式不需要在服务端设置 vhost_http_port 和 vhost_https_port:
[common]
server_addr = x.x.x.x
server_port = 9999
token = yourtokenhere
[WEB]
type = tcp
local_ip = 127.0.0.1
local_port = 3333
remote_port = 6666
访问:http://x.x.x.x:6666
这种方式需要在服务端设置 vhost_http_port = 6666,也就是和客户端配置的 remote_port 相同。
[common]
server_addr = x.x.x.x
server_port = 9999
token = yourtokenhere
[web]
type = http
local_ip = 127.0.0.1
local_port = 3333
remote_port = 6666
custom_domains = x.x.x.x
同样访问:http://x.x.x.x:6666
在没用 frp 之前,使用的是 Nginx 搭建的静态文件服务器,只适用于公网服务器,如果是内网,还是得用 frp!下面是使用 frp 搭建静态文件下载服务的客户端配置:
[common]
server_addr = x.x.x.x
server_port = 9999
token = yourtokenhere
[file-server]
type = tcp
remote_port = 6666
plugin = static_file
plugin_local_path = /home/k8scat/files
plugin_strip_prefix = download
plugin_http_user = k8scat
plugin_http_passwd = yourpasswd
配置说明:
以上就是高性能的内网穿透工具frp使用场景的详细内容,更多关于内网穿透工具frp的资料请关注编程网其它相关文章!
--结束END--
本文标题: 高性能的内网穿透工具frp使用场景
本文链接: https://www.lsjlt.com/news/151752.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-21
2024-05-21
2024-05-21
2024-05-21
2024-05-13
2024-05-13
2024-05-11
2024-05-11
2024-05-10
2024-05-07
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0