Skip to content

Commit

Permalink
update some doc to toml config format (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
fatedier authored Oct 13, 2023
1 parent 20b44e5 commit 5d069dd
Show file tree
Hide file tree
Showing 14 changed files with 393 additions and 292 deletions.
36 changes: 17 additions & 19 deletions content/zh-cn/docs/Concepts/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,30 @@
title: "概念"
weight: 3
description: >
一些概念,理解它们有助于您更好地了解和使用 frp。
了解以下概念有助于更好地理解和使用 frp。
---

## 原理
## 工作原理

frp 主要由 **客户端(frpc)****服务端(frps)** 组成,服务端通常部署在具有公网 IP 的机器上,客户端通常部署在需要穿透的内网服务所在的机器上
frp 主要由两个组件组成:客户端(frpc) 和 服务端(frps)。通常情况下,服务端部署在具有公网 IP 地址的机器上,而客户端部署在需要穿透的内网服务所在的机器上

内网服务由于没有公网 IP,不能被非局域网内的其他用户访问。

用户通过访问服务端的 frps,由 frp 负责根据请求的端口或其他信息将请求路由到对应的内网机器,从而实现通信。
由于内网服务缺乏公网 IP 地址,因此无法直接被非局域网内的用户访问。用户通过访问服务端的 frps,frp 负责根据请求的端口或其他信息将请求路由到相应的内网机器,从而实现通信。

## 代理

在 frp 中一个代理对应一个需要暴露的内网服务。一个客户端支持同时配置多个代理
在 frp 中,一个代理对应一个需要公开访问的内网服务。一个客户端可以同时配置多个代理,以满足不同的需求

## 代理类型

frp 支持多种代理类型来适配不同的使用场景。

| 类型 | 描述 |
| :--- | :--- |
| tcp | 单纯的 TCP 端口映射,服务端会根据不同的端口路由到不同的内网服务。 |
| udp | 单纯的 UDP 端口映射,服务端会根据不同的端口路由到不同的内网服务。 |
| http | 针对 HTTP 应用定制了一些额外的功能,例如修改 Host Header,增加鉴权。 |
| https | 针对 HTTPS 应用定制了一些额外的功能。 |
| stcp | 安全的 TCP 内网代理,需要在被访问者和访问者的机器上都部署 frpc,不需要在服务端暴露端口。 |
| sudp | 安全的 UDP 内网代理,需要在被访问者和访问者的机器上都部署 frpc,不需要在服务端暴露端口。 |
| xtcp | 点对点内网穿透代理,功能同 stcp,但是流量不需要经过服务器中转。 |
| tcpmux | 支持服务端 TCP 端口的多路复用,通过同一个端口访问不同的内网服务。 |
frp 支持多种代理类型,以适应不同的使用场景。以下是一些常见的代理类型:

- **TCP**:提供纯粹的 TCP 端口映射,使服务端能够根据不同的端口将请求路由到不同的内网服务。
- **UDP**:提供纯粹的 UDP 端口映射,与 TCP 代理类似,但用于 UDP 流量。
- **HTTP**:专为 HTTP 应用设计,支持修改 Host Header 和增加鉴权等额外功能。
- **HTTPS**:类似于 HTTP 代理,但专门用于处理 HTTPS 流量。
- **STCP**:提供安全的 TCP 内网代理,要求在被访问者和访问者的机器上都部署 frpc,不需要在服务端暴露端口。
- **SUDP**:提供安全的 UDP 内网代理,与 STCP 类似,需要在被访问者和访问者的机器上都部署 frpc,不需要在服务端暴露端口。
- **XTCP**:点对点内网穿透代理,与 STCP 类似,但流量不需要经过服务器中转。
- **TCPMUX**:支持服务端 TCP 端口的多路复用,允许通过同一端口访问不同的内网服务。

每种代理类型适用于不同的使用情境,您可以根据需求选择合适的代理类型来配置 frp。
2 changes: 1 addition & 1 deletion content/zh-cn/docs/Examples/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
title: "示例"
weight: 4
description: >
这里包括多个常见的使用场景和配置示例,你可以用来亲自部署和体验这些示例
在这里,您将找到多个常见的使用场景和配置示例,可供您用来亲自部署和体验这些示例
---
51 changes: 31 additions & 20 deletions content/zh-cn/docs/Examples/dns.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,47 @@
title: "转发 DNS 查询请求"
weight: 20
description: >
这个示例通过简单配置 UDP 类型的代理转发 DNS 查询请求
本示例演示如何通过简单配置 UDP 类型的代理来实现 DNS 查询请求的转发
---

DNS 查询请求通常使用 UDP 协议,frp 支持对内网 UDP 服务的穿透,配置方式和 TCP 基本一致
DNS 查询请求通常使用 UDP 协议,frp 支持对内网 UDP 服务的穿透,配置方式与 TCP 类似

1. frps.ini 内容如下:
### 步骤

```ini
[common]
bind_port = 7000
1. **配置 frps.toml**

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

```toml
bindPort = 7000
```

2. frpc.ini 内容如下:
2. **配置 frpc.toml**

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

```ini
[common]
server_addr = x.x.x.x
server_port = 7000
```toml
serverAddr = "x.x.x.x"
serverPort = 7000

[dns]
type = udp
local_ip = 8.8.8.8
local_port = 53
remote_port = 6000
[[proxies]]
name = "dns"
type = "udp"
localIP = "8.8.8.8"
localPort = 53
remotePort = 6000
```

这里反代了 Google 的 DNS 查询服务器的地址,仅仅用于测试 UDP 代理,并无实际意义。
请注意,这里示例中反代了 Google 的 DNS 查询服务器的地址,仅用于测试 UDP 代理,并没有实际意义。

3. **启动 frps 和 frpc**

分别启动 frps 和 frpc。

3. 分别启动 frps 和 frpc。
4. **测试 DNS 查询请求**

4. 通过 dig 测试 UDP 包转发是否成功,预期会返回 `www.baidu.com` 域名的解析结果
使用以下命令通过 `dig` 工具测试 UDP 包转发是否成功,预期会返回 `www.baidu.com` 域名的解析结果

`dig @x.x.x.x -p 6000 www.baidu.com`
```bash
dig @x.x.x.x -p 6000 www.baidu.com
```
52 changes: 30 additions & 22 deletions content/zh-cn/docs/Examples/https2http.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,46 @@
title: "为本地 HTTP 服务启用 HTTPS"
weight: 35
description: >
通过 `https2http` 插件可以让本地 HTTP 服务转换成 HTTPS 服务对外提供
使用 `https2http` 插件将本地 HTTP 服务转换为 HTTPS 服务,以供外部访问
---

1. frps.ini 内容如下:
### 步骤

```ini
[common]
bind_port = 7000
vhost_https_port = 443
1. **配置 frps.toml**

```toml
bindPort = 7000
vhostHTTPSPort = 443
```

2. frpc.ini 内容如下:
2. **配置 frpc.toml**

```ini
[common]
server_addr = x.x.x.x
server_port = 7000
```toml
serverAddr = "x.x.x.x"
serverPort = 7000

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

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

# HTTPS 证书相关的配置
plugin_crt_path = ./server.crt
plugin_key_path = ./server.key
plugin_host_header_rewrite = 127.0.0.1
plugin_header_X-From-Where = frp
crtPath = "./server.crt"
keyPath = "./server.key"
hostHeaderRewrite = "127.0.0.1"
requestHeaders.set.x-from-where = "frp"
```

3. 分别启动 frps 和 frpc。
请注意,您需要根据您的域名和证书路径自行更改上述配置。

3. **启动 frps 和 frpc**

4. **访问 HTTPS 服务**

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

4. 通过浏览器访问 `https://test.yourdomain.com`
通过按照以上步骤进行配置,您将能够为本地 HTTP 服务启用 HTTPS,以实现安全的外部访问
79 changes: 47 additions & 32 deletions content/zh-cn/docs/Examples/multiple-ssh-over-same-port.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,66 @@
title: "多个 SSH 服务复用同一端口"
weight: 10
description: >
这个示例通过 tcpmux 类型的代理,实现多个 ssh 服务通过同一个端口暴露。与此类似,只要是能够支持 HTTP Connect 代理连接方式的客户端,都可以通过这种方式来实现对端口的复用
通过使用 tcpmux 类型的代理,您可以实现多个 SSH 服务通过同一端口进行暴露。这种方法还适用于任何支持 HTTP Connect 代理连接方式的客户端,以实现端口的复用
---

1. 在具有公网 IP 的机器上部署 frps,修改 frps.ini 文件,这里使用了最简化的配置:
### 步骤

```ini
[common]
bind_port = 7000
tcpmux_httpconnect_port = 5002
1. **在具有公网 IP 的机器上部署 frps**

修改 frps.toml 文件以包含以下内容(这里使用了最简化的配置):

```toml
bindPort = 7000
tcpmuxHTTPConnectPort = 5002
```

2. 在内网机器 A 上部署 frpc,配置文件:
2. **在内网机器 A 上部署 frpc**

```ini
[common]
server_addr = x.x.x.x
server_port = 7000
创建 frpc 配置文件,例如 frpc.ini,然后将以下内容添加到配置文件中:

[ssh1]
type = tcpmux
multiplexer = httpconnect
custom_domains = machine-a.example.com
local_ip = 127.0.0.1
local_port = 22
```toml
serverAddr = "x.x.x.x"
serverPort = 7000

[[proxies]]
name = "ssh1"
type = "tcpmux"
multiplexer = "httpconnect"
customDomains = ["machine-a.example.com"]
localIP = "127.0.0.1"
localPort = 22
```

3. 在内网机器 B 上部署另一个 frpc,配置文件:
3. **在内网机器 B 上部署另一个 frpc**

创建 frpc 配置文件,例如 frpc.toml,然后将以下内容添加到配置文件中:

```ini
[common]
server_addr = x.x.x.x
server_port = 7000
```toml
serverAddr = "x.x.x.x"
serverPort = 7000

[ssh2]
type = tcpmux
multiplexer = httpconnect
custom_domains = machine-b.example.com
local_ip = 127.0.0.1
local_port = 22
[[proxies]]
name = "ssh2"
type = "tcpmux"
multiplexer = "httpconnect"
customDomains = ["machine-b.example.com"]
localIP = "127.0.0.1"
localPort = 22
```

4. 通过 SSH ProxyCommand 访问内网机器 A,假设用户名为 test:
4. **通过 SSH ProxyCommand 访问内网机器 A**

`ssh -o 'proxycommand socat - PROXY:x.x.x.x:machine-a.example.com:22,proxyport=5002' test@machine-a`
使用 SSH ProxyCommand 访问内网机器 A,假设用户名为 test。使用以下命令:

访问内网机器 B,区别只在于域名不同,假设用户名为 test:
```bash
ssh -o 'proxycommand socat - PROXY:x.x.x.x:machine-a.example.com:22,proxyport=5002' test@machine-a
```

要访问内网机器 B,只需更改域名,假设用户名仍然为 test:

```bash
ssh -o 'proxycommand socat - PROXY:x.x.x.x:machine-b.example.com:22,proxyport=5002' test@machine-b
```

`ssh -o 'proxycommand socat - PROXY:x.x.x.x:machine-b.example.com:22,proxyport=5002' test@machine-b`
通过按照以上步骤进行配置,您可以实现多个 SSH 服务复用同一端口,以便在具有公网 IP 的机器上进行访问。
50 changes: 30 additions & 20 deletions content/zh-cn/docs/Examples/ssh.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,46 @@
title: "通过 SSH 访问内网机器"
weight: 5
description: >
这个示例通过简单配置 TCP 类型的代理让用户访问到内网的服务器
通过简单配置 TCP 类型的代理,使用户能够访问内网服务器
---

1. 在具有公网 IP 的机器上部署 frps,修改 frps.ini 文件,这里使用了最简化的配置,设置了 frp 服务器用户接收客户端连接的端口:
### 步骤

```ini
[common]
bind_port = 7000
1. **在具有公网 IP 的机器上部署 frps**

部署 frps 并编辑 frps.toml 文件。以下是简化的配置,其中设置了 frp 服务器用于接收客户端连接的端口:

```toml
bindPort = 7000
```

2. 在需要被访问的内网机器上(SSH 服务通常监听在 22 端口)部署 frpc,修改 frpc.ini 文件,假设 frps 所在服务器的公网 IP 为 x.x.x.x:
2. **在需要被访问的内网机器上部署 frpc**

部署 frpc 并编辑 frpc.toml 文件,假设 frps 所在服务器的公网 IP 地址为 x.x.x.x。以下是示例配置:

```ini
[common]
server_addr = x.x.x.x
server_port = 7000
```toml
serverAddr = "x.x.x.x"
serverPort = 7000

[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000
[[proxies]]
name = "ssh"
type = "tcp"
localIP = "127.0.0.1"
localPort = 22
remotePort = 6000
```

`local_ip` 和 `local_port` 配置为本地需要暴露到公网的服务地址和端口。`remote_port` 表示在 frp 服务端监听的端口,访问此端口的流量将会被转发到本地服务对应的端口。
* `localIP` 和 `localPort` 配置为需要从公网访问的内网服务的地址和端口。
* `remotePort` 表示在 frp 服务端监听的端口,访问此端口的流量将被转发到本地服务的相应端口。

3. 分别启动 frps 和 frpc
3. **启动 frps 和 frpc**

4. 通过 SSH 访问内网机器,假设用户名为 test:
4. **通过 SSH 访问内网机器**

`ssh -oPort=6000 [email protected]`
使用以下命令通过 SSH 访问内网机器,假设用户名为 test:

```bash
ssh -o Port=6000 [email protected]
```

frp 会将请求 `x.x.x.x:6000` 的流量转发到内网机器的 22 端口。
frp 将请求发送到 `x.x.x.x:6000` 的流量转发到内网机器的 22 端口。
Loading

0 comments on commit 5d069dd

Please sign in to comment.