diff --git a/docs/tutorials/api/overview.md b/docs/tutorials/api/overview.md index 2dba5cc..22507a7 100644 --- a/docs/tutorials/api/overview.md +++ b/docs/tutorials/api/overview.md @@ -30,6 +30,8 @@ GOST可以通过开启Web API服务使用RESTful API和GOST进程进行交互。 type: tcp api: addr: :18080 + # unix domain socket + # addr: unix:///var/run/gost.sock pathPrefix: /api accesslog: true auth: diff --git a/docs/tutorials/metrics.md b/docs/tutorials/metrics.md index 6684803..2ccda2c 100644 --- a/docs/tutorials/metrics.md +++ b/docs/tutorials/metrics.md @@ -35,6 +35,8 @@ GOST内部通过[Prometheus](https://prometheus.io/)的指标(Metrics)来提供 metrics: addr: :9000 + # unix domain socket + # addr: unix:///var/run/gost.sock path: /metrics auth: username: user diff --git a/docs/tutorials/reverse-proxy.md b/docs/tutorials/reverse-proxy.md index f9c3b69..6220cce 100644 --- a/docs/tutorials/reverse-proxy.md +++ b/docs/tutorials/reverse-proxy.md @@ -388,14 +388,18 @@ services: nodes: - name: example-com addr: example.com:80 - filter: - host: example.com + # filter: + # host: example.com + matcher: + rule: Host(`example.com`) http: host: test.example.com - name: example-org addr: example.org:80 - filter: - host: example.org + # filter: + # host: example.org + matcher: + rule: Host(`example.org`) http: host: test.example.org:80 ``` @@ -408,7 +412,7 @@ curl --resolve example.com:80:127.0.0.1 http://example.com ### 自定义请求头 -通过设置`http.header`选项可以自定义请求头部信息,如果所设置的头部字段已存在则会被覆盖。 +通过设置`http.requestHeader`选项可以自定义请求头部信息,如果所设置的头部字段已存在则会被覆盖。 ```yaml hl_lines="16-20" services: @@ -424,20 +428,24 @@ services: nodes: - name: example-com addr: example.com:80 - filter: - host: example.com + # filter: + # host: example.com + matcher: + rule: Host(`example.com`) http: - header: + requestHeader: User-Agent: gost/3.0.0 foo: bar bar: 123 # host: test.example.com - name: example-org addr: example.org:80 - filter: - host: example.org + # filter: + # host: example.org + matcher: + rule: Host(`example.org`) http: - header: + requestHeader: User-Agent: curl/7.81.0 foo: bar bar: baz @@ -464,8 +472,10 @@ services: nodes: - name: example-com addr: example.com:80 - filter: - host: example.com + # filter: + # host: example.com + matcher: + rule: Host(`example.com`) http: responseHeader: foo: bar @@ -492,8 +502,10 @@ services: nodes: - name: example-com addr: example.com:80 - filter: - host: example.com + # filter: + # host: example.com + matcher: + rule: Host(`example.com`) http: auth: username: user @@ -504,7 +516,7 @@ services: ### URL路径重写 -通过设置`http.rewrite`选项定义URL路径重写规则。 +通过设置`http.rewriteURL`选项定义URL路径重写规则。 ```yaml hl_lines="16-21" services: @@ -520,20 +532,22 @@ services: nodes: - name: example-com addr: example.com:80 - filter: - host: example.com + # filter: + # host: example.com + matcher: + rule: Host(`example.com`) http: - rewrite: + rewriteURL: - match: /api/login replacement: /user/login - match: /api/(.*) replacement: /$1 ``` -`rewrite.match` (string) +`rewriteURL.match` (string) : 指定路径匹配模式(支持正则表达式)。 -`rewrite.replacement` (string) +`rewriteURL.replacement` (string) : 设置路径替换内容。 `http://example.com/api/login`会被重写为`http://example.com/user/login`。 @@ -558,8 +572,10 @@ services: nodes: - name: example-com addr: example.com:80 - filter: - host: example.com + # filter: + # host: example.com + matcher: + rule: Host(`example.com`) http: rewriteBody: - match: foo @@ -594,8 +610,10 @@ services: nodes: - name: example-com addr: example.com:443 - filter: - host: example.com + # filter: + # host: example.com + matcher: + rule: Host(`example.com`) tls: secure: true serverName: example.com @@ -646,12 +664,16 @@ services: nodes: - name: example-com addr: example.com:80 - filter: - host: .example.com + # filter: + # host: .example.com + matcher: + rule: Host(`.example.com`) - name: example-org addr: example.org:80 - filter: - host: .example.org + # filter: + # host: .example.org + matcher: + rule: Host(`.example.org`) ``` ```bash @@ -676,12 +698,16 @@ services: nodes: - name: example-com addr: example.com:80 - filter: - host: .example.com + # filter: + # host: .example.com + matcher: + rule: Host(`.example.com`) - name: example-org addr: example.org:80 - filter: - host: .example.org + # filter: + # host: .example.org + matcher: + rule: Host(`.example.org`) ``` ```bash diff --git a/en/docs/tutorials/api/overview.md b/en/docs/tutorials/api/overview.md index dc15407..f80e2d5 100644 --- a/en/docs/tutorials/api/overview.md +++ b/en/docs/tutorials/api/overview.md @@ -8,13 +8,13 @@ GOST can use the RESTful API to interact with the GOST process by starting the W === "CLI" - ```sh + ```bash gost -L http://:8080 -api :18080 ``` or - ```sh + ```bash gost -L http://:8080 -api "user:pass@:18080?pathPrefix=/api&accesslog=true" ``` @@ -30,6 +30,8 @@ GOST can use the RESTful API to interact with the GOST process by starting the W type: tcp api: addr: :18080 + # also support unix domain socket + # addr: unix:///var/run/gost.sock pathPrefix: /api accesslog: true auth: diff --git a/en/docs/tutorials/metrics.md b/en/docs/tutorials/metrics.md index 4688cfe..b785cd3 100644 --- a/en/docs/tutorials/metrics.md +++ b/en/docs/tutorials/metrics.md @@ -35,6 +35,8 @@ Use the `metrics` option to enable metrics, which is disabled by default. metrics: addr: :9000 + # also support unix domain socket + # addr: unix:///var/run/gost.sock path: /metrics auth: username: user diff --git a/en/docs/tutorials/reverse-proxy.md b/en/docs/tutorials/reverse-proxy.md index b7ce0c3..2fc3659 100644 --- a/en/docs/tutorials/reverse-proxy.md +++ b/en/docs/tutorials/reverse-proxy.md @@ -386,14 +386,18 @@ services: nodes: - name: example-com addr: example.com:80 - filter: - host: example.com + # filter: + # host: example.com + matcher: + rule: Host(`example.com`) http: host: test.example.com - name: example-org addr: example.org:80 - filter: - host: example.org + # filter: + # host: example.org + matcher: + rule: Host(`example.org`) http: host: test.example.org:80 ``` @@ -406,7 +410,7 @@ When requesting http://example.com, the Host in the HTTP request header sent to ### Custom Request Header -The request header can be customized by setting the `http.header` option, if the header field already exists, it will be overwritten. +The request header can be customized by setting the `http.requestHeader` option, if the header field already exists, it will be overwritten. ```yaml hl_lines="16-20" services: @@ -422,20 +426,24 @@ services: nodes: - name: example-com addr: example.com:80 - filter: - host: example.com + # filter: + # host: example.com + matcher: + rule: Host(`example.com`) http: - header: + requestHeader: User-Agent: gost/3.0.0 foo: bar bar: 123 # host: test.example.com - name: example-org addr: example.org:80 - filter: - host: example.org + # filter: + # host: example.org + matcher: + rule: Host(`example.org`) http: - header: + requestHeader: User-Agent: curl/7.81.0 foo: bar bar: baz @@ -462,8 +470,10 @@ services: nodes: - name: example-com addr: example.com:80 - filter: - host: example.com + # filter: + # host: example.com + matcher: + rule: Host(`example.com`) http: responseHeader: foo: bar @@ -490,8 +500,10 @@ services: nodes: - name: example-com addr: example.com:80 - filter: - host: example.com + # filter: + # host: example.com + matcher: + rule: Host(`example.com`) http: auth: username: user @@ -502,7 +514,7 @@ When requesting http://example.com directly, HTTP status code 401 will be return ### Rewrite URL Path -Define URL path rewriting rules by setting the `http.rewrite` option. +Define URL path rewriting rules by setting the `http.rewriteURL` option. ```yaml hl_lines="16-21" services: @@ -518,20 +530,22 @@ services: nodes: - name: example-com addr: example.com:80 - filter: - host: example.com + # filter: + # host: example.com + matcher: + rule: Host(`example.com`) http: - rewrite: + rewriteURL: - match: /api/login replacement: /user/login - match: /api/(.*) replacement: /$1 ``` -`rewrite.match` (string) +`rewriteURL.match` (string) : specify path matching pattern (supports regular expression). -`rewrite.replacement` (string) +`rewriteURL.replacement` (string) : set the path replacement content. `http://example.com/api/login` will be rewritten to `http://example.com/user/login`. @@ -556,8 +570,10 @@ services: nodes: - name: example-com addr: example.com:80 - filter: - host: example.com + # filter: + # host: example.com + matcher: + rule: Host(`example.com`) http: rewriteBody: - match: foo @@ -592,8 +608,10 @@ services: nodes: - name: example-com addr: example.com:443 - filter: - host: example.com + # filter: + # host: example.com + matcher: + rule: Host(`example.com`) tls: secure: true serverName: example.com @@ -643,12 +661,16 @@ services: nodes: - name: example-com addr: example.com:80 - filter: - host: .example.com + # filter: + # host: .example.com + matcher: + rule: Host(`.example.com`) - name: example-org addr: example.org:80 - filter: - host: .example.org + # filter: + # host: .example.org + matcher: + rule: Host(`.example.org`) ``` ```bash @@ -673,12 +695,16 @@ services: nodes: - name: example-com addr: example.com:80 - filter: - host: .example.com + # filter: + # host: .example.com + matcher: + rule: Host(`.example.com`) - name: example-org addr: example.org:80 - filter: - host: .example.org + # filter: + # host: .example.org + matcher: + rule: Host(`.example.org`) ``` ```bash