|
## 如何反代 `https://voice.oaifree.com`
**如果你不需要将 `https://voice.oaifree.com` 反代到自己的域名,可以忽略以下操作。**
**方法一:Cloudflare Worker**
```javascript
export default {
async fetch(request, env) {
const url = new URL(request.url);
url.host = 'voice.oaifree.com';
return fetch(new Request(url, request));
}
}
```
**方法二:Nginx**
```config
location / {
proxy_pass https://voice.oaifree.com;
proxy_ssl_server_name on;
}
```
**反代到其他域名**
**假设你反代的 Voice 域名是 `https://voice.abc.com`,需要调整代码,通过 `X-Voice-Base` 头指定:**
**方法一:Cloudflare Worker**
```javascript
export default {
async fetch(request, env) {
const url = new URL(request.url);
url.host = 'new.oaifree.com';
const modifiedRequest = new Request(url, request);
modifiedRequest.headers.set('X-Voice-Base', 'https://voice.abc.com');
return fetch(modifiedRequest);
}
}
```
**方法二:Nginx**
```config
location / {
proxy_pass https://new.oaifree.com;
proxy_set_header X-Voice-Base "https://voice.abc.com";
proxy_ssl_server_name on;
}
``` |
|