Skip to content

Commit 248dcd3

Browse files
committed
完善文档
1 parent 0497d3d commit 248dcd3

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,26 @@ Flags:
106106
经过`mars`的流量可在web页查看
107107

108108
### Nginx
109-
请求包含特定header, 则转发给`mars`
110-
```ini
111-
proxy_set_header X-Mars-Debug 0;
112-
proxy_set_header Host $http_host;
109+
请求包含特定header, 则转发给`mars`, 由`mars`访问实际的后端
110+
111+
原配置
112+
```nginx
113+
proxy_pass http://172.16.10.103:8080;
114+
```
115+
116+
使用`mars`后的配置
117+
```nginx
118+
set $targetHost $host;
119+
120+
if ($http_x_mars_debug = "1") {
121+
set $targetHost "172.16.10.103:8080";
122+
}
123+
124+
proxy_set_header X-Mars-Host $host;
125+
proxy_set_header Host $targetHost;
113126
if ($http_x_mars_debug = "1") {
114127
proxy_pass http://localhost:8888;
128+
break;
115129
}
116130
```
117131

internal/common/recorder/recorder.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func (r *Recorder) BeforeRequest(ctx *goproxy.Context) {
8888
if host := ctx.Req.Header.Get("X-Mars-Host"); host != "" {
8989
ctx.Req.Host = host
9090
}
91+
ctx.Req.Header.Del("X-Mars-Host")
9192
ctx.Req.Header.Del("X-Mars-Debug")
9293
if r.interceptor != nil {
9394
r.interceptor.BeforeRequest(ctx)

0 commit comments

Comments
 (0)