Skip to content

Commit 0497d3d

Browse files
committed
完善文档
1 parent 82ca9d4 commit 0497d3d

File tree

7 files changed

+54
-6
lines changed

7 files changed

+54
-6
lines changed

README.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Mars
22

3-
HTTP(S)代理服务器, 用于抓包调试
3+
HTTP(S)代理, 用于抓包调试
44

55
功能特性
66
----
77
* 作为普通HTTP(S)代理服务器使用
88
* 抓包调试, web页面查看流量
9-
* 流量信息持久化到`leveldb`中, 可用于后期分析
9+
* 流量持久化到`leveldb`中, 可用于后期分析
1010
* 拦截请求自定义逻辑
1111

1212
## 目录
@@ -16,6 +16,9 @@ HTTP(S)代理服务器, 用于抓包调试
1616
* [源码安装](#源码安装)
1717
* [配置文件](#配置文件)
1818
* [命令](#命令)
19+
* [结合其他程序使用](#结合其他程序使用)
20+
* [Nginx](#nginx)
21+
* [frp](#frp)
1922
* [开发](#开发)
2023
* [服务端](#服务端)
2124
* [前端](#前端)
@@ -98,6 +101,43 @@ Flags:
98101
* `make package-all` 生成Windows、Linux、Mac的压缩包
99102

100103

104+
## 结合其他程序使用
105+
106+
经过`mars`的流量可在web页查看
107+
108+
### Nginx
109+
请求包含特定header, 则转发给`mars`
110+
```ini
111+
proxy_set_header X-Mars-Debug 0;
112+
proxy_set_header Host $http_host;
113+
if ($http_x_mars_debug = "1") {
114+
proxy_pass http://localhost:8888;
115+
}
116+
```
117+
118+
### frp
119+
120+
原配置
121+
122+
```ini
123+
[web]
124+
type = http
125+
local_ip = 127.0.0.1
126+
local_port = 80
127+
subdomain = test
128+
```
129+
130+
使用`mars`后的配置
131+
132+
```ini
133+
[web]
134+
type = http
135+
local_ip = 127.0.0.1
136+
local_port = 8888
137+
subdomain = test
138+
host_header_rewrite = 127.0.0.1:80
139+
```
140+
101141
## 开发
102142

103143
### 服务端

internal/common/recorder/recorder.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ func (r *Recorder) Auth(ctx *goproxy.Context, rw http.ResponseWriter) {}
8585

8686
// BeforeRequest 请求发送前处理
8787
func (r *Recorder) BeforeRequest(ctx *goproxy.Context) {
88+
if host := ctx.Req.Header.Get("X-Mars-Host"); host != "" {
89+
ctx.Req.Host = host
90+
}
91+
ctx.Req.Header.Del("X-Mars-Debug")
8892
if r.interceptor != nil {
8993
r.interceptor.BeforeRequest(ctx)
9094
}

internal/statik/statik.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>mars</title><link href=public/static/css/app.456feddc172b076dc828362d1077a2d8.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=public/static/js/manifest.047c133009965c5daaca.js></script><script type=text/javascript src=public/static/js/vendor.99215b533571af4c9162.js></script><script type=text/javascript src=public/static/js/app.09205449c28ac7d19798.js></script></body></html>
1+
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>mars</title><link href=public/static/css/app.456feddc172b076dc828362d1077a2d8.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=public/static/js/manifest.047c133009965c5daaca.js></script><script type=text/javascript src=public/static/js/vendor.99215b533571af4c9162.js></script><script type=text/javascript src=public/static/js/app.9d937801f5fd861a638b.js></script></body></html>

web/public/static/js/app.09205449c28ac7d19798.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)