Skip to content

Commit

Permalink
update md
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanshudong committed Feb 12, 2025
1 parent aed5930 commit 08b4d7b
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 107 deletions.
20 changes: 10 additions & 10 deletions conf/GatwayServer.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
auto_proxy=1
flow_report_obj=tars.GatewayServer.FlowControlObj
<base>
# tup 回包大小限制
# tup 回包大小限制()
rspsize=5242880
#tup_host 如果不配置,那么所有host开头的,且没有path或者path为 / , 也判断为 tup 请求, 例如: prx.tup.whup.com|127.0.0.1|192.168.2.123
tup_host=
Expand All @@ -17,9 +17,9 @@
<proxy>
# servant = server_full_obj [| hash_type [| http header key] ]
# hash_type: 0, 轮训; 1: requestid, 2: http头, 3: client ip
# Hello=TestApp.HelloServer.HelloObj | 1
# Hello=TestApp.HelloServer.HelloObj | 2 | X-GUID
#Hello=TestApp.HelloServer.HelloObj | 3
# Hello = TestApp.HelloServer.HelloObj | 1
# Hello = TestApp.HelloServer.HelloObj | 2 | X-GUID
# Hello = TestApp.HelloServer.HelloObj | 3

hello = TestApp.HelloServer.HelloObj

Expand All @@ -35,8 +35,8 @@
</proxy>

<proxy_interface_blacklist>
#proxy 接口黑名单
#servant:func1|func2|....
# proxy 接口黑名单
# servant:func1|func2|....
hello:func1|func2
login:func1
</proxy_interface_blacklist>
Expand Down Expand Up @@ -88,15 +88,14 @@
</wx_login>
</auth>


#http头:值, 转到proxy某个服务
<httpheader>
Q-gUID:344bfdf1afb146ffa68b2bd69a57f193 = test
Q-GUID:344bfdf1afb146ffa68b2bd69a57f193 = test
Q-GUID:b7392a2d60604eac81892f6f9c0232f7 = test
</httpheader>

<http_retcode>
# 定义哪些返回码做超时容错处理,哪些返回码做出错容灾处理
<http_retcode>
# 定义哪些返回码做超时容错处理,哪些返回码做出错容灾处理, 通常不需要调整
inactive=2|6
timeout=1|3
</http_retcode>
Expand Down Expand Up @@ -184,6 +183,7 @@
# </proxy2_path>
</http_router>

# mysql数据库配置
<db>
charset=utf8
dbhost =db.tars.com
Expand Down
17 changes: 5 additions & 12 deletions conf/httpheader.conf
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@
</special_headers>
</tup>

#tup协议代理,定制回包http头
#json协议代理,定制回包http头
<json>
# default_headers 为该协议默认加的 http 头
<default_headers>
#Content-Type=application/json
#test-header=ttttttt
Access-Control-Allow-Origin=*
Access-Control-Allow-Methods=POST, GET, OPTIONS
Access-Control-Max-Age=86400
Expand All @@ -51,8 +50,8 @@

# special_headers 为其他需要特殊配置的列表
<special_headers>
# 下面可以有多组不同的列表, 每组可以有多个servant
<for_h5_call>
# 下面可以有多组不同的列表, 每组可以有多个servant, <h5_call> 名字可以自定义
<h5_call>
# servant_station_list 列表,对tup或者json来说,为servant, 对http来说,则为station, 多个之间用 | 分割
servant_station_list=tarsalarm
# headers 为需要添加的http头
Expand All @@ -61,9 +60,8 @@
Access-Control-Allow-Methods=POST, GET, OPTIONS
Access-Control-Max-Age=86400
Access-Control-Allow-Headers=Content-Type,X-Requested-With

</headers>
</for_h5_call>
</h5_call>
</special_headers>
</json>

Expand All @@ -86,15 +84,10 @@
</headers>
</special_1>

<special_2>
servant_station_list=xx|xx2
<headers>

</headers>
</special_2>
</special_headers>
</http>

# options 是控制跨域请求的协议
<options>
# default_headers 为该协议默认加的 http 头
<default_headers>
Expand Down
6 changes: 6 additions & 0 deletions doc/Gateway.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,9 @@ General HTTP protocol proxy log format description:
**Http access log:**

Client ip | access time | host | referer | request url | request packet size | http method | site ID | backend address | http return status code | response time | time (ms) | response packet size | UA | error message

## 11. Other notes

- To support cross-domain requests, please refer to the options configuration in httpheader.conf
- For security, it is recommended to configure auto_proxy=0 in GatewayServer.conf, that is, not to discover proxies through the master control, but to directly use the proxy configuration in the configuration file
- If you want to support https, you need to compile tarscpp with ssl enabled first, then configure the template of GatewayServer, configure the certificate, please refer to the tarscpp enable ssl document.
6 changes: 6 additions & 0 deletions doc/Gateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,9 @@ TARS-tup & TARS-JSON 协议代理请求响应日志格式说明:
**Http access 日志:**

客户端 ip | 访问时间 | host | referer | 请求 url | 请求包大小 | http 方法 | 站点 ID | 后端地址 | http 返回状态码 | 响应时间 | 耗时(ms) | 响应包大小 | UA | 出错信息

### 12. 其他说明

- 要支持跨域请求, 请参考httpheader.conf中的options配置
- 为了安全, 建议GatewayServer.conf中的auto_proxy配置为0, 即不通过主控发现代理, 而是直接使用配置文件中的代理配置
- 如果要支持https, 需要先将tarscpp启用ssl编译, 然后配置GatewayServer的模板, 配置好证书, 请参考tarscpp启用ssl文档.
Loading

0 comments on commit 08b4d7b

Please sign in to comment.