FRP内网穿透

 火... [复制链接]  4859查看
 楼主| 易西 发表于 2024-3-28 12:51:35 | 显示全部楼层
安全地暴露内网服务
通过创建一个只有授权用户能够访问的 SSH 服务代理,实现内网服务的安全暴露。
https://gofrp.org/zh-cn/docs/examples/stcp/
参考

步骤
配置 frps.toml

在 frps.toml 文件中添加以下内容:

bindPort = 7000
部署 frpc 客户端并配置

在需要将内网服务暴露到公网的机器上部署 frpc,并创建如下配置:

serverAddr = "x.x.x.x"
serverPort = 7000

[[proxies]]
name = "secret_ssh"
type = "stcp"
# 只有与此处设置的 secretKey 一致的用户才能访问此服务
secretKey = "abcdefg"
localIP = "127.0.0.1"
localPort = 22
在访问者机器上部署并配置 frpc

在想要访问内网服务的机器上也部署 frpc,并创建如下配置:

serverAddr = "x.x.x.x"
serverPort = 7000

[[visitors]]
name = "secret_ssh_visitor"
type = "stcp"
# 要访问的 stcp 代理的名字
serverName = "secret_ssh"
secretKey = "abcdefg"
# 绑定本地端口以访问 SSH 服务
bindAddr = "127.0.0.1"
bindPort = 6000
通过 SSH 访问内网机器

使用以下命令通过 SSH 访问内网机器,假设用户名为 test:

ssh -o Port=6000 test@127.0.0.1
[发帖际遇]: 易西 乐于助人,奖励 5 贡献. 幸运榜 / 衰神榜
 楼主| 易西 发表于 2024-3-30 16:36:26 | 显示全部楼层
对外提供简单的文件访问服务
https://gofrp.org/zh-cn/docs/examples/static-file/
 楼主| 易西 发表于 2024-3-30 16:36:39 | 显示全部楼层

对外提供简单的文件访问服务
https://gofrp.org/zh-cn/docs/examples/static-file/

对外提供简单的文件访问服务
通过配置 static_file 客户端插件,您可以将本地文件暴露在公网上,以供其他人访问。
通过使用 static_file 插件,您可以轻松地提供一个基于 HTTP 的文件访问服务,让其他人可以访问您指定的文件。

步骤
配置 frps.toml

在 frps.toml 文件中添加以下内容:

bindPort = 7000
配置 frpc.toml

在 frpc.toml 文件中添加以下内容,确保设置合适的文件路径、用户名和密码:

serverAddr = "x.x.x.x"
serverPort = 7000

[[proxies]]
name = "test_static_file"
type = "tcp"
remotePort = 6000
[proxies.plugin]
type = "static_file"
# 本地文件目录,对外提供访问
localPath = "/tmp/file"
# URL 中的前缀,将被去除,保留的内容即为要访问的文件路径
stripPrefix = "static"
httpUser = "abc"
httpPassword = "abc"
请根据实际情况修改 localPath、stripPrefix、httpUser 和 httpPassword。

启动 frps 和 frpc

通过浏览器访问文件

使用浏览器访问 http://x.x.x.x:6000/static/,以查看位于 /tmp/file 目录下的文件。系统会要求输入您设置的用户名和密码。

最后修改 March 13, 2024: update docs for v0.55 (#75) (66067f8)
 楼主| 易西 发表于 2024-3-30 21:57:40 | 显示全部楼层
https://gofrp.org/zh-cn/docs/examples/https2http/
为本地 HTTP 服务启用 HTTPS

使用 https2http 插件将本地 HTTP 服务转换为 HTTPS 服务,以供外部访问。
步骤
配置 frps.toml

bindPort = 7000
vhostHTTPSPort = 443
配置 frpc.toml

serverAddr = "x.x.x.x"
serverPort = 7000

[[proxies]]
name = "test_htts2http"
type = "https"
customDomains = ["test.yourdomain.com"]

[proxies.plugin]
type = "https2http"
localAddr = "127.0.0.1:80"

# HTTPS 证书相关的配置
crtPath = "./server.crt"
keyPath = "./server.key"
hostHeaderRewrite = "127.0.0.1"
requestHeaders.set.x-from-where = "frp"
请注意,您需要根据您的域名和证书路径自行更改上述配置。

启动 frps 和 frpc

访问 HTTPS 服务

打开您的 Web 浏览器,访问 https://test.yourdomain.com

通过按照以上步骤进行配置,您将能够为本地 HTTP 服务启用 HTTPS,以实现安全的外部访问。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

邮箱|首页|小黑屋|吾侪 ( 蜀ICP备2020029307号-4 )

GMT+8, 2025-11-5 22:30 , Processed in 0.061275 second(s), 17 queries , APCu On.

Powered by Discuz! X3.5

Copyright © , 吾侪网

快速回复 返回顶部 返回列表