Skip to content

Commit

Permalink
完善文档
Browse files Browse the repository at this point in the history
  • Loading branch information
ouqiang committed Nov 25, 2018
1 parent 0497d3d commit 248dcd3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,26 @@ Flags:
经过`mars`的流量可在web页查看

### Nginx
请求包含特定header, 则转发给`mars`
```ini
proxy_set_header X-Mars-Debug 0;
proxy_set_header Host $http_host;
请求包含特定header, 则转发给`mars`, 由`mars`访问实际的后端

原配置
```nginx
proxy_pass http://172.16.10.103:8080;
```

使用`mars`后的配置
```nginx
set $targetHost $host;
if ($http_x_mars_debug = "1") {
set $targetHost "172.16.10.103:8080";
}
proxy_set_header X-Mars-Host $host;
proxy_set_header Host $targetHost;
if ($http_x_mars_debug = "1") {
proxy_pass http://localhost:8888;
break;
}
```

Expand Down
1 change: 1 addition & 0 deletions internal/common/recorder/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func (r *Recorder) BeforeRequest(ctx *goproxy.Context) {
if host := ctx.Req.Header.Get("X-Mars-Host"); host != "" {
ctx.Req.Host = host
}
ctx.Req.Header.Del("X-Mars-Host")
ctx.Req.Header.Del("X-Mars-Debug")
if r.interceptor != nil {
r.interceptor.BeforeRequest(ctx)
Expand Down

0 comments on commit 248dcd3

Please sign in to comment.