# ReverseProxyService
> 反向代理管理服务

---

## createReverseProxy
> 创建反向代理

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/ReverseProxyService/createReverseProxy`
- RPC：`rpc createReverseProxy (CreateReverseProxyRequest) returns (CreateReverseProxyResponse);`

**请求对象 (`CreateReverseProxyRequest`)**

```json
{
  "schedulingJSON": "bytes // 可选项，调度设置 json:scheduling",
  "primaryOriginsJSON": "bytes // 可选项，主要源站 json:origin_refs",
  "backupOriginsJSON": "bytes // 可选项，备用源站 json:origin_refs"
}
```

**响应对象 (`CreateReverseProxyResponse`)**

```json
{
  "reverseProxyId": "int64 // 反向代理ID"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/ReverseProxyService/createReverseProxy" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## findEnabledReverseProxy
> 查找反向代理

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/ReverseProxyService/findEnabledReverseProxy`
- RPC：`rpc findEnabledReverseProxy (FindEnabledReverseProxyRequest) returns (FindEnabledReverseProxyResponse);`

**请求对象 (`FindEnabledReverseProxyRequest`)**

```json
{
  "reverseProxyId": "int64 // 反向代理ID"
}
```

**响应对象 (`FindEnabledReverseProxyResponse`)**

```json
{
  "reverseProxy": "ReverseProxy // 反向代理信息"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/ReverseProxyService/findEnabledReverseProxy" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## findEnabledReverseProxyConfig
> 查找反向代理配置

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/ReverseProxyService/findEnabledReverseProxyConfig`
- RPC：`rpc findEnabledReverseProxyConfig (FindEnabledReverseProxyConfigRequest) returns (FindEnabledReverseProxyConfigResponse);`

**请求对象 (`FindEnabledReverseProxyConfigRequest`)**

```json
{
  "reverseProxyId": "int64 // 反向代理ID"
}
```

**响应对象 (`FindEnabledReverseProxyConfigResponse`)**

```json
{
  "reverseProxyJSON": "bytes // 反向代理配置"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/ReverseProxyService/findEnabledReverseProxyConfig" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## updateReverseProxy
> 修改反向代理设置

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/ReverseProxyService/updateReverseProxy`
- RPC：`rpc updateReverseProxy (UpdateReverseProxyRequest) returns (RPCSuccess);`

**请求对象 (`UpdateReverseProxyRequest`)**

```json
{
  "reverseProxyId": "int64 // 反向代理ID",
  "requestHostType": "int32 // 可选参数，回源主机名类型：0 跟随CDN域名，1跟随源站，2自定义",
  "requestHost": "string // 可选参数，自定义回源主机名",
  "requestHostExcludingPort": "bool // 可选参数，回源主机名中去除端口",
  "requestURI": "string // 可选参数，请求URI",
  "stripPrefix": "string // 可选参数，去除URI前缀",
  "autoFlush": "bool // 可选参数，自动刷新",
  "addHeaders": "[]string // 可选参数，可以添加的请求报头",
  "connTimeoutJSON": "bytes // 可选参数，连接超时时间",
  "readTimeoutJSON": "bytes // 可选参数，读取超时时间",
  "idleTimeoutJSON": "bytes // 可选参数，空闲连接超时时间",
  "maxConns": "int32 // 可选参数，最大连接数",
  "maxIdleConns": "int32 // 可选参数，最大空闲连接数",
  "proxyProtocolJSON": "bytes // 可选参数，PROXY Protocol设置",
  "followRedirects": "bool // 可选参数，跳转跟随",
  "retry50X": "bool // 可选参数，是否启用50X重试",
  "retry40X": "bool // 可选参数，是否启用40X重试"
}
```

**响应对象 (`RPCSuccess`)**

```json
{}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/ReverseProxyService/updateReverseProxy" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## updateReverseProxyBackupOrigins
> 修改备用源站信息

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/ReverseProxyService/updateReverseProxyBackupOrigins`
- RPC：`rpc updateReverseProxyBackupOrigins (UpdateReverseProxyBackupOriginsRequest) returns (RPCSuccess);`

**请求对象 (`UpdateReverseProxyBackupOriginsRequest`)**

```json
{
  "reverseProxyId": "int64 // 反向代理ID",
  "originsJSON": "bytes // 源站配置 json:origin_refs"
}
```

**响应对象 (`RPCSuccess`)**

```json
{}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/ReverseProxyService/updateReverseProxyBackupOrigins" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## updateReverseProxyPrimaryOrigins
> 修改主要源站信息

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/ReverseProxyService/updateReverseProxyPrimaryOrigins`
- RPC：`rpc updateReverseProxyPrimaryOrigins (UpdateReverseProxyPrimaryOriginsRequest) returns (RPCSuccess);`

**请求对象 (`UpdateReverseProxyPrimaryOriginsRequest`)**

```json
{
  "reverseProxyId": "int64 // 反向代理ID",
  "originsJSON": "bytes // 源站配置 json:origin_refs"
}
```

**响应对象 (`RPCSuccess`)**

```json
{}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/ReverseProxyService/updateReverseProxyPrimaryOrigins" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## updateReverseProxyScheduling
> 修改反向代理的调度算法

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/ReverseProxyService/updateReverseProxyScheduling`
- RPC：`rpc updateReverseProxyScheduling (UpdateReverseProxySchedulingRequest) returns (RPCSuccess);`

**请求对象 (`UpdateReverseProxySchedulingRequest`)**

```json
{
  "reverseProxyId": "int64 // 反向代理ID",
  "schedulingJSON": "bytes // 调度配置 json:scheduling"
}
```

**响应对象 (`RPCSuccess`)**

```json
{}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/ReverseProxyService/updateReverseProxyScheduling" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---
