📚 Complete documentation overhaul
### New Documentation: - **URL Format Guide**: Complete guide for image resizer URL patterns - **Hybrid Architecture**: Vercel Edge + Quoter integration strategy - **Updated How-it-works**: Comprehensive system architecture with diagrams - **Enhanced Configuration**: Security settings, troubleshooting, Vercel integration ### Documentation Structure: 📋 Architecture & Principles: - 🚀 How Quoter Works (detailed system architecture) - 🔀 Hybrid Architecture (Vercel + Quoter best practices) - 📐 URL Format (complete resizer URL guide) 🛡️ Security & Configuration: - 🔒 Security & DDoS Protection (comprehensive guide) - ⚙️ Configuration (updated with new settings) - 🚀 Deployment & 📊 Monitoring 🎨 Integrations: - Vercel OG Integration guides - Edge Function examples ### Key Features Documented: - Complete URL patterns for image resizing - Security rate limiting configuration - Hybrid upload (Quoter) + download (Vercel) strategy - JWT validation and session management - Multi-cloud storage (Storj + AWS fallback) - Performance optimization techniques - Production deployment strategies All documentation is now production-ready and includes practical examples! 📖✨
This commit is contained in:
@@ -9,11 +9,11 @@ Quoter использует следующие переменные окруже
|
||||
| Переменная | Описание | Пример |
|
||||
|------------|----------|--------|
|
||||
| `REDIS_URL` | URL для подключения к Redis | `redis://localhost:6379` |
|
||||
| `CORE_URL` | URL для подключения к API ядра | `https://api.example.com/graphql` |
|
||||
| `STORJ_ACCESS_KEY` | Ключ доступа к Storj S3 | `your-storj-access-key` |
|
||||
| `STORJ_SECRET_KEY` | Секретный ключ Storj S3 | `your-storj-secret-key` |
|
||||
| `AWS_ACCESS_KEY` | Ключ доступа к AWS S3 | `your-aws-access-key` |
|
||||
| `AWS_SECRET_KEY` | Секретный ключ AWS S3 | `your-aws-secret-key` |
|
||||
| `AWS_ACCESS_KEY` | Ключ доступа к AWS S3 (fallback) | `your-aws-access-key` |
|
||||
| `AWS_SECRET_KEY` | Секретный ключ AWS S3 (fallback) | `your-aws-secret-key` |
|
||||
| `JWT_SECRET` | Секрет для валидации JWT токенов | `your-jwt-secret-key` |
|
||||
|
||||
### Опциональные переменные
|
||||
|
||||
@@ -28,26 +28,31 @@ Quoter использует следующие переменные окруже
|
||||
## Пример .env файла
|
||||
|
||||
```bash
|
||||
# Redis
|
||||
# Redis (обязательно)
|
||||
REDIS_URL=redis://localhost:6379
|
||||
|
||||
# Core API
|
||||
CORE_URL=https://api.example.com/graphql
|
||||
# JWT Authentication (обязательно)
|
||||
JWT_SECRET=your-super-secret-jwt-key
|
||||
|
||||
# Storj S3
|
||||
# Storj S3 - основное хранилище (обязательно)
|
||||
STORJ_ACCESS_KEY=your-storj-access-key
|
||||
STORJ_SECRET_KEY=your-storj-secret-key
|
||||
STORJ_END_POINT=https://gateway.storjshare.io
|
||||
STORJ_BUCKET_NAME=discours-io
|
||||
|
||||
# AWS S3
|
||||
# AWS S3 - fallback хранилище (обязательно)
|
||||
AWS_ACCESS_KEY=your-aws-access-key
|
||||
AWS_SECRET_KEY=your-aws-secret-key
|
||||
AWS_END_POINT=https://s3.amazonaws.com
|
||||
|
||||
# Server
|
||||
# Server настройки
|
||||
PORT=8080
|
||||
RUST_LOG=info
|
||||
|
||||
# Security (опционально)
|
||||
MAX_PAYLOAD_SIZE=524288000 # 500MB
|
||||
MAX_PATH_LENGTH=1000
|
||||
MAX_HEADERS_COUNT=50
|
||||
```
|
||||
|
||||
## Настройка Redis
|
||||
@@ -120,6 +125,37 @@ RUST_LOG=info cargo run
|
||||
RUST_LOG=debug cargo run
|
||||
```
|
||||
|
||||
## Дополнительные настройки
|
||||
|
||||
### Настройки безопасности
|
||||
```bash
|
||||
# Rate limiting (requests per window)
|
||||
GENERAL_RATE_LIMIT=100 # Общие запросы: 100/мин
|
||||
UPLOAD_RATE_LIMIT=10 # Загрузка: 10/5мин
|
||||
AUTH_RATE_LIMIT=20 # Аутентификация: 20/15мин
|
||||
|
||||
# Блокировка (секунды)
|
||||
GENERAL_BLOCK_DURATION=300 # 5 минут
|
||||
UPLOAD_BLOCK_DURATION=600 # 10 минут
|
||||
AUTH_BLOCK_DURATION=1800 # 30 минут
|
||||
```
|
||||
|
||||
### Настройки квот
|
||||
```bash
|
||||
# Пользовательские квоты
|
||||
MAX_USER_QUOTA_BYTES=12884901888 # 12 ГБ на пользователя
|
||||
MAX_SINGLE_FILE_BYTES=524288000 # 500 МБ на файл
|
||||
```
|
||||
|
||||
### Vercel интеграция
|
||||
```bash
|
||||
# CORS для Vercel Edge Functions
|
||||
ALLOWED_ORIGINS=https://discours.io,https://new.discours.io,https://vercel.app
|
||||
|
||||
# Health check endpoint
|
||||
HEALTH_CHECK_ENABLED=true
|
||||
```
|
||||
|
||||
## Проверка конфигурации
|
||||
|
||||
Запустите сервер и проверьте логи:
|
||||
@@ -132,6 +168,63 @@ RUST_LOG=info cargo run
|
||||
|
||||
```
|
||||
[INFO] Started
|
||||
[INFO] Security config: max_payload=500 MB, upload_rate_limit=10/300s
|
||||
[WARN] caching AWS filelist...
|
||||
[WARN] cached 1234 files
|
||||
```
|
||||
|
||||
### Проверка endpoints
|
||||
```bash
|
||||
# Health check
|
||||
curl http://localhost:8080/health
|
||||
|
||||
# User info (требует токен)
|
||||
curl -H "Authorization: Bearer $TOKEN" http://localhost:8080/
|
||||
|
||||
# Upload test (требует токен)
|
||||
curl -X POST -H "Authorization: Bearer $TOKEN" \
|
||||
-F "file=@test.jpg" http://localhost:8080/
|
||||
```
|
||||
|
||||
### Проверка безопасности
|
||||
```bash
|
||||
# Rate limiting test
|
||||
for i in {1..110}; do curl http://localhost:8080/ & done
|
||||
|
||||
# Должно показать 429 после 100 запросов
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Частые проблемы
|
||||
|
||||
**1. Redis connection failed**
|
||||
```bash
|
||||
# Проверьте Redis
|
||||
redis-cli ping
|
||||
# Должно вернуть: PONG
|
||||
```
|
||||
|
||||
**2. S3 credentials invalid**
|
||||
```bash
|
||||
# Проверьте доступ к Storj
|
||||
aws s3 ls --endpoint-url=https://gateway.storjshare.io \
|
||||
--profile storj
|
||||
|
||||
# Проверьте доступ к AWS
|
||||
aws s3 ls --profile aws
|
||||
```
|
||||
|
||||
**3. JWT validation failed**
|
||||
```bash
|
||||
# Проверьте JWT_SECRET
|
||||
echo $JWT_SECRET
|
||||
# Должен быть установлен и совпадать с core API
|
||||
```
|
||||
|
||||
**4. Rate limiting не работает**
|
||||
```bash
|
||||
# Проверьте Redis keys
|
||||
redis-cli KEYS "rate_limit:*"
|
||||
# Должны появляться ключи при запросах
|
||||
```
|
||||
Reference in New Issue
Block a user