mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:40:25 +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
|
||||
# 初始化
|
||||
npm run setup # 会随机生成后台账号密码信息,存储在 data/Init.json
|
||||
npm run setup # 会随机生成后台账号密码信息,存储在 data/init.json
|
||||
|
||||
# 启动服务
|
||||
npm run service:start:daemon # 后台运行(推荐)
|
||||
@@ -211,7 +211,7 @@ npm run service:status
|
||||
|
||||
浏览器访问:`http://你的服务器IP:3000/web`
|
||||
|
||||
默认管理员账号:data/Init.json 中寻找
|
||||
默认管理员账号:data/init.json 中寻找
|
||||
|
||||
### 2. 添加Claude账户
|
||||
|
||||
@@ -312,10 +312,16 @@ redis-cli ping
|
||||
**1. 安装nginx和获取SSL证书**
|
||||
```bash
|
||||
# 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为例)
|
||||
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配置示例**
|
||||
|
||||
14
README_EN.md
14
README_EN.md
@@ -193,7 +193,7 @@ module.exports = {
|
||||
|
||||
```bash
|
||||
# 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
|
||||
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`
|
||||
|
||||
Default admin account: Look in data/Init.json
|
||||
Default admin account: Look in data/init.json
|
||||
|
||||
### 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**
|
||||
```bash
|
||||
# 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)
|
||||
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**
|
||||
|
||||
@@ -121,7 +121,10 @@ class ClaudeAccountService {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'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,
|
||||
timeout: 30000
|
||||
@@ -182,7 +185,7 @@ class ClaudeAccountService {
|
||||
const expiresAt = parseInt(accountData.expiresAt);
|
||||
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...`);
|
||||
try {
|
||||
const refreshResult = await this.refreshAccountToken(accountId);
|
||||
|
||||
Reference in New Issue
Block a user