Skip to content

Commit 23bb763

Browse files
authored
Merge pull request #1696 from fatedier/dev
bump version to v0.32.0
2 parents 487c8d7 + 859a330 commit 23bb763

File tree

1,078 files changed

+48167
-332287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,078 files changed

+48167
-332287
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ _testmain.go
2727
bin/
2828
packages/
2929
test/bin/
30+
vendor/
3031

3132
# Cache
3233
*.swp

Diff for: .travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ language: go
33

44
go:
55
- 1.12.x
6+
- 1.13.x
67

78
install:
89
- make

Diff for: Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export PATH := $(GOPATH)/bin:$(PATH)
2+
export GO111MODULE=on
23

34
all: fmt build
45

Diff for: README.md

+107-7
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ frp also has a P2P connect mode.
3030
* [Using Environment Variables](#using-environment-variables)
3131
* [Dashboard](#dashboard)
3232
* [Admin UI](#admin-ui)
33+
* [Monitor](#monitor)
34+
* [Prometheus](#prometheus)
3335
* [Authenticating the Client](#authenticating-the-client)
36+
* [Token Authentication](#token-authentication)
37+
* [OIDC Authentication](#oidc-authentication)
3438
* [Encryption and Compression](#encryption-and-compression)
3539
* [TLS](#tls)
3640
* [Hot-Reloading frpc configuration](#hot-reloading-frpc-configuration)
@@ -49,9 +53,10 @@ frp also has a P2P connect mode.
4953
* [Get Real IP](#get-real-ip)
5054
* [HTTP X-Forwarded-For](#http-x-forwarded-for)
5155
* [Proxy Protocol](#proxy-protocol)
52-
* [Require HTTP Basic auth (password) for web services](#require-http-basic-auth-password-for-web-services)
53-
* [Custom subdomain names](#custom-subdomain-names)
54-
* [URL routing](#url-routing)
56+
* [Require HTTP Basic Auth (Password) for Web Services](#require-http-basic-auth-password-for-web-services)
57+
* [Custom Subdomain Names](#custom-subdomain-names)
58+
* [URL Routing](#url-routing)
59+
* [TCP Port Multiplexing](#tcp-port-multiplexing)
5560
* [Connecting to frps via HTTP PROXY](#connecting-to-frps-via-http-proxy)
5661
* [Range ports mapping](#range-ports-mapping)
5762
* [Client Plugins](#client-plugins)
@@ -435,9 +440,59 @@ admin_pwd = admin
435440

436441
Then visit `http://127.0.0.1:7400` to see admin UI, with username and password both being `admin` by default.
437442

443+
### Monitor
444+
445+
When dashboard is enabled, frps will save monitor data in cache. It will be cleared after process restart.
446+
447+
Prometheus is also supported.
448+
449+
#### Prometheus
450+
451+
Enable dashboard first, then configure `enable_prometheus = true` in `frps.ini`.
452+
453+
`http://{dashboard_addr}/metrics` will provide prometheus monitor data.
454+
438455
### Authenticating the Client
439456

440-
Always use the same `token` in the `[common]` section in `frps.ini` and `frpc.ini`.
457+
There are 2 authentication methods to authenticate frpc with frps.
458+
459+
You can decide which one to use by configuring `authentication_method` under `[common]` in `frpc.ini` and `frps.ini`.
460+
461+
Configuring `authenticate_heartbeats = true` under `[common]` will use the configured authentication method to add and validate authentication on every heartbeat between frpc and frps.
462+
463+
Configuring `authenticate_new_work_conns = true` under `[common]` will do the same for every new work connection between frpc and frps.
464+
465+
#### Token Authentication
466+
467+
When specifying `authentication_method = token` under `[common]` in `frpc.ini` and `frps.ini` - token based authentication will be used.
468+
469+
Make sure to specify the same `token` in the `[common]` section in `frps.ini` and `frpc.ini` for frpc to pass frps validation
470+
471+
#### OIDC Authentication
472+
473+
When specifying `authentication_method = oidc` under `[common]` in `frpc.ini` and `frps.ini` - OIDC based authentication will be used.
474+
475+
OIDC stands for OpenID Connect, and the flow used is called [Client Credentials Grant](https://tools.ietf.org/html/rfc6749#section-4.4).
476+
477+
To use this authentication type - configure `frpc.ini` and `frps.ini` as follows:
478+
479+
```ini
480+
# frps.ini
481+
[common]
482+
authentication_method = oidc
483+
oidc_issuer = https://example-oidc-issuer.com/
484+
oidc_audience = https://oidc-audience.com/.default
485+
```
486+
487+
```ini
488+
# frpc.ini
489+
[common]
490+
authentication_method = oidc
491+
oidc_client_id = 98692467-37de-409a-9fac-bb2585826f18 # Replace with OIDC client ID
492+
oidc_client_secret = oidc_secret
493+
oidc_audience = https://oidc-audience.com/.default
494+
oidc_token_endpoint_url = https://example-oidc-endpoint.com/oauth2/v2.0/token
495+
```
441496

442497
### Encryption and Compression
443498

@@ -461,6 +516,8 @@ Config `tls_enable = true` in the `[common]` section to `frpc.ini` to enable thi
461516

462517
For port multiplexing, frp sends a first byte `0x17` to dial a TLS connection.
463518

519+
To enforce `frps` to only accept TLS connections - configure `tls_only = true` in the `[common]` section in `frps.ini`.
520+
464521
### Hot-Reloading frpc configuration
465522

466523
The `admin_addr` and `admin_port` fields are required for enabling HTTP API:
@@ -712,7 +769,7 @@ proxy_protocol_version = v2
712769

713770
You can enable Proxy Protocol support in nginx to expose user's real IP in HTTP header `X-Real-IP`, and then read `X-Real-IP` header in your web service for the real IP.
714771

715-
### Require HTTP Basic auth (password) for web services
772+
### Require HTTP Basic Auth (Password) for Web Services
716773

717774
Anyone who can guess your tunnel URL can access your local web server unless you protect it with a password.
718775

@@ -732,7 +789,7 @@ http_pwd = abc
732789

733790
Visit `http://test.example.com` in the browser and now you are prompted to enter the username and password.
734791

735-
### Custom subdomain names
792+
### Custom Subdomain Names
736793

737794
It is convenient to use `subdomain` configure for http and https types when many people share one frps server.
738795

@@ -755,7 +812,7 @@ Now you can visit your web service on `test.frps.com`.
755812

756813
Note that if `subdomain_host` is not empty, `custom_domains` should not be the subdomain of `subdomain_host`.
757814

758-
### URL routing
815+
### URL Routing
759816

760817
frp supports forwarding HTTP requests to different backend web services by url routing.
761818

@@ -778,6 +835,49 @@ locations = /news,/about
778835

779836
HTTP requests with URL prefix `/news` or `/about` will be forwarded to **web02** and other requests to **web01**.
780837

838+
### TCP Port Multiplexing
839+
840+
frp supports receiving TCP sockets directed to different proxies on a single port on frps, similar to `vhost_http_port` and `vhost_https_port`.
841+
842+
The only supported TCP port multiplexing method available at the moment is `httpconnect` - HTTP CONNECT tunnel.
843+
844+
When setting `tcpmux_httpconnect_port` to anything other than 0 in frps under `[common]`, frps will listen on this port for HTTP CONNECT requests.
845+
846+
The host of the HTTP CONNECT request will be used to match the proxy in frps. Proxy hosts can be configured in frpc by configuring `custom_domain` and / or `subdomain` under `type = tcpmux` proxies, when `multiplexer = httpconnect`.
847+
848+
For example:
849+
850+
```ini
851+
# frps.ini
852+
[common]
853+
bind_port = 7000
854+
tcpmux_httpconnect_port = 1337
855+
```
856+
857+
```ini
858+
# frpc.ini
859+
[common]
860+
server_addr = x.x.x.x
861+
server_port = 7000
862+
863+
[proxy1]
864+
type = tcpmux
865+
multiplexer = httpconnect
866+
custom_domains = test1
867+
868+
[proxy2]
869+
type = tcpmux
870+
multiplexer = httpconnect
871+
custom_domains = test2
872+
```
873+
874+
In the above configuration - frps can be contacted on port 1337 with a HTTP CONNECT header such as:
875+
876+
```
877+
CONNECT test1 HTTP/1.1\r\n\r\n
878+
```
879+
and the connection will be routed to `proxy1`.
880+
781881
### Connecting to frps via HTTP PROXY
782882

783883
frpc can connect to frps using HTTP proxy if you set OS environment variable `HTTP_PROXY`, or if `http_proxy` is set in frpc.ini file.

Diff for: README_zh.md

+101-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ frp 是一个可用于内网穿透的高性能的反向代理应用,支持 tcp
2626
* [配置文件模版渲染](#配置文件模版渲染)
2727
* [Dashboard](#dashboard)
2828
* [Admin UI](#admin-ui)
29-
* [身份验证](#身份验证)
29+
* [监控](#监控)
30+
* [Prometheus](#prometheus)
31+
* [客户端身份验证](#客户端身份验证)
32+
* [Token](#token)
33+
* [OIDC](#oidc)
3034
* [加密与压缩](#加密与压缩)
3135
* [TLS](#tls)
3236
* [客户端热加载配置文件](#客户端热加载配置文件)
@@ -48,6 +52,7 @@ frp 是一个可用于内网穿透的高性能的反向代理应用,支持 tcp
4852
* [通过密码保护你的 web 服务](#通过密码保护你的-web-服务)
4953
* [自定义二级域名](#自定义二级域名)
5054
* [URL 路由](#url-路由)
55+
* [TCP 端口复用类型](#tcp-端口复用类型)
5156
* [通过代理连接 frps](#通过代理连接-frps)
5257
* [范围端口映射](#范围端口映射)
5358
* [客户端插件](#客户端插件)
@@ -459,9 +464,56 @@ admin_pwd = admin
459464

460465
如果想要在外网环境访问 Admin UI,将 7400 端口映射出去即可,但需要重视安全风险。
461466

462-
### 身份验证
467+
### 监控
463468

464-
服务端和客户端的 common 配置中的 `token` 参数一致则身份验证通过。
469+
frps 当启用 Dashboard 后,会默认开启内部的监控,数据存放在内存中,每次重启进程后会清空,监控数据可以通过 dashboard 的地址发送 HTTP 请求获取。
470+
471+
目前还支持 Prometheus 作为可选的监控系统。
472+
473+
#### Prometheus
474+
475+
`frps.ini` 中启用 Dashboard,并且设置 `enable_prometheus = true`,则通过 `http://{dashboard_addr}/metrics` 可以获取到 Prometheus 的监控数据。
476+
477+
### 客户端身份验证
478+
479+
目前 frpc 和 frps 之间支持两种身份验证方式,`token``oidc`
480+
481+
通过 `frpc.ini``frps.ini``[common]` section 的 `authentication_method` 参数配置需要使用的验证方法。
482+
483+
`authenticate_heartbeats = true` 将会在每一个心跳包中附加上鉴权信息。
484+
485+
`authenticate_new_work_conns = true` 将会在每次建立新的工作连接时附加上鉴权信息。
486+
487+
#### Token
488+
489+
`authentication_method = token`,将会启用基于 token 的验证方式。
490+
491+
需要在 `frpc.ini``frps.ini``[common]` section 中设置相同的 `token`
492+
493+
#### OIDC
494+
495+
`authentication_method = oidc`,将会启用基于 OIDC 的身份验证。
496+
497+
验证流程参考 [Client Credentials Grant](https://tools.ietf.org/html/rfc6749#section-4.4)
498+
499+
启用这一验证方式,配置 `frpc.ini``frps.ini` 如下:
500+
501+
```ini
502+
# frps.ini
503+
[common]
504+
authentication_method = oidc
505+
oidc_issuer = https://example-oidc-issuer.com/
506+
oidc_audience = https://oidc-audience.com/.default
507+
```
508+
509+
```ini
510+
[common]
511+
authentication_method = oidc
512+
oidc_client_id = 98692467-37de-409a-9fac-bb2585826f18 # Replace with OIDC client ID
513+
oidc_client_secret = oidc_secret
514+
oidc_audience = https://oidc-audience.com/.default
515+
oidc_token_endpoint_url = https://example-oidc-endpoint.com/oauth2/v2.0/token
516+
```
465517

466518
### 加密与压缩
467519

@@ -487,6 +539,8 @@ use_compression = true
487539

488540
为了端口复用,frp 建立 TLS 连接的第一个字节为 0x17。
489541

542+
通过将 frps.ini 的 `[common]``tls_only` 设置为 true,可以强制 frps 只接受 TLS 连接。
543+
490544
**注意: 启用此功能后除 xtcp 外,不需要再设置 use_encryption。**
491545

492546
### 客户端热加载配置文件
@@ -824,6 +878,50 @@ locations = /news,/about
824878

825879
按照上述的示例配置后,`web.yourdomain.com` 这个域名下所有以 `/news` 以及 `/about` 作为前缀的 URL 请求都会被转发到 web02,其余的请求会被转发到 web01。
826880

881+
### TCP 端口复用类型
882+
883+
frp 支持将单个端口收到的连接路由到不同的代理,类似 `vhost_http_port``vhost_https_port`
884+
885+
目前支持的复用器只有 `httpconnect`
886+
887+
当在 `frps.ini``[common]` 中设置 `tcpmux_httpconnect_port`,frps 将会监听在这个端口,接收 HTTP CONNECT 请求。
888+
889+
frps 会根据 HTTP CONNECT 请求中的 host 路由到不同的后端代理。
890+
891+
示例配置如下:
892+
893+
```ini
894+
# frps.ini
895+
[common]
896+
bind_port = 7000
897+
tcpmux_httpconnect_port = 1337
898+
```
899+
900+
```ini
901+
# frpc.ini
902+
[common]
903+
server_addr = x.x.x.x
904+
server_port = 7000
905+
906+
[proxy1]
907+
type = tcpmux
908+
multiplexer = httpconnect
909+
custom_domains = test1
910+
911+
[proxy2]
912+
type = tcpmux
913+
multiplexer = httpconnect
914+
custom_domains = test2
915+
```
916+
917+
通过上面的配置,frps 如果接收到 HTTP CONNECT 请求内容:
918+
919+
```
920+
CONNECT test1 HTTP/1.1\r\n\r\n
921+
```
922+
923+
该连接将会被路由到 proxy1 。
924+
827925
### 通过代理连接 frps
828926

829927
在只能通过代理访问外网的环境内,frpc 支持通过 HTTP PROXY 和 frps 进行通信。

0 commit comments

Comments
 (0)