mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
feat: 优化SSL证书获取推荐和token刷新机制
- 将README中的certbot推荐改为acme.sh,更轻量且功能更强 - 中英文文档同步更新SSL证书获取方式 - 调整token刷新提前时间从10秒改为60秒,提供更充足的缓冲时间 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
14
README.md
14
README.md
@@ -194,7 +194,7 @@ module.exports = {
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 初始化
|
# 初始化
|
||||||
npm run setup # 会随机生成后台账号密码信息,存储在 data/Init.json
|
npm run setup # 会随机生成后台账号密码信息,存储在 data/init.json
|
||||||
|
|
||||||
# 启动服务
|
# 启动服务
|
||||||
npm run service:start:daemon # 后台运行(推荐)
|
npm run service:start:daemon # 后台运行(推荐)
|
||||||
@@ -211,7 +211,7 @@ npm run service:status
|
|||||||
|
|
||||||
浏览器访问:`http://你的服务器IP:3000/web`
|
浏览器访问:`http://你的服务器IP:3000/web`
|
||||||
|
|
||||||
默认管理员账号:data/Init.json 中寻找
|
默认管理员账号:data/init.json 中寻找
|
||||||
|
|
||||||
### 2. 添加Claude账户
|
### 2. 添加Claude账户
|
||||||
|
|
||||||
@@ -312,10 +312,16 @@ redis-cli ping
|
|||||||
**1. 安装nginx和获取SSL证书**
|
**1. 安装nginx和获取SSL证书**
|
||||||
```bash
|
```bash
|
||||||
# Ubuntu/Debian
|
# Ubuntu/Debian
|
||||||
sudo apt install nginx certbot python3-certbot-nginx
|
sudo apt install nginx
|
||||||
|
|
||||||
|
# 安装 acme.sh
|
||||||
|
curl https://get.acme.sh | sh
|
||||||
|
source ~/.bashrc
|
||||||
|
|
||||||
# 获取免费SSL证书(以Let's Encrypt为例)
|
# 获取免费SSL证书(以Let's Encrypt为例)
|
||||||
sudo certbot --nginx -d your-domain.com
|
acme.sh --issue -d your-domain.com --nginx
|
||||||
|
# 或者使用 standalone 模式
|
||||||
|
# acme.sh --issue -d your-domain.com --standalone
|
||||||
```
|
```
|
||||||
|
|
||||||
**2. nginx配置示例**
|
**2. nginx配置示例**
|
||||||
|
|||||||
14
README_EN.md
14
README_EN.md
@@ -193,7 +193,7 @@ module.exports = {
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Initialize
|
# Initialize
|
||||||
npm run setup # Will randomly generate admin account password info, stored in data/Init.json
|
npm run setup # Will randomly generate admin account password info, stored in data/init.json
|
||||||
|
|
||||||
# Start service
|
# Start service
|
||||||
npm run service:start:daemon # Run in background (recommended)
|
npm run service:start:daemon # Run in background (recommended)
|
||||||
@@ -210,7 +210,7 @@ npm run service:status
|
|||||||
|
|
||||||
Browser visit: `http://your-server-IP:3000/web`
|
Browser visit: `http://your-server-IP:3000/web`
|
||||||
|
|
||||||
Default admin account: Look in data/Init.json
|
Default admin account: Look in data/init.json
|
||||||
|
|
||||||
### 2. Add Claude Account
|
### 2. Add Claude Account
|
||||||
|
|
||||||
@@ -310,10 +310,16 @@ It's recommended to use nginx reverse proxy and configure SSL certificate: (The
|
|||||||
**1. Install nginx and obtain SSL certificate**
|
**1. Install nginx and obtain SSL certificate**
|
||||||
```bash
|
```bash
|
||||||
# Ubuntu/Debian
|
# Ubuntu/Debian
|
||||||
sudo apt install nginx certbot python3-certbot-nginx
|
sudo apt install nginx
|
||||||
|
|
||||||
|
# Install acme.sh
|
||||||
|
curl https://get.acme.sh | sh
|
||||||
|
source ~/.bashrc
|
||||||
|
|
||||||
# Get free SSL certificate (using Let's Encrypt as example)
|
# Get free SSL certificate (using Let's Encrypt as example)
|
||||||
sudo certbot --nginx -d your-domain.com
|
acme.sh --issue -d your-domain.com --nginx
|
||||||
|
# Or use standalone mode
|
||||||
|
# acme.sh --issue -d your-domain.com --standalone
|
||||||
```
|
```
|
||||||
|
|
||||||
**2. nginx configuration example**
|
**2. nginx configuration example**
|
||||||
|
|||||||
@@ -121,7 +121,10 @@ class ClaudeAccountService {
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Accept': 'application/json, text/plain, */*',
|
'Accept': 'application/json, text/plain, */*',
|
||||||
'User-Agent': 'claude-relay-service/1.0.0'
|
'User-Agent': 'claude-cli/1.0.53 (external, cli)',
|
||||||
|
'Accept-Language': 'en-US,en;q=0.9',
|
||||||
|
'Referer': 'https://claude.ai/',
|
||||||
|
'Origin': 'https://claude.ai'
|
||||||
},
|
},
|
||||||
httpsAgent: agent,
|
httpsAgent: agent,
|
||||||
timeout: 30000
|
timeout: 30000
|
||||||
@@ -182,7 +185,7 @@ class ClaudeAccountService {
|
|||||||
const expiresAt = parseInt(accountData.expiresAt);
|
const expiresAt = parseInt(accountData.expiresAt);
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
|
|
||||||
if (!expiresAt || now >= (expiresAt - 10000)) { // 10秒提前刷新
|
if (!expiresAt || now >= (expiresAt - 60000)) { // 60秒提前刷新
|
||||||
logger.info(`🔄 Token expired/expiring for account ${accountId}, attempting refresh...`);
|
logger.info(`🔄 Token expired/expiring for account ${accountId}, attempting refresh...`);
|
||||||
try {
|
try {
|
||||||
const refreshResult = await this.refreshAccountToken(accountId);
|
const refreshResult = await this.refreshAccountToken(accountId);
|
||||||
|
|||||||
Reference in New Issue
Block a user