✨ Features: - Migrated ALL files to new S3 structure (Projects, Contacts, Accounts, HelpDesk, Invoice, etc.) - Added Nextcloud folder buttons to ALL modules - Fixed Nextcloud editor integration - WebSocket server for real-time updates - Redis Pub/Sub integration - File path manager for organized storage - Redis caching for performance (Functions.php) 📁 New Structure: Documents/Project/ProjectName_ID/file_docID.ext Documents/Contacts/FirstName_LastName_ID/file_docID.ext Documents/Accounts/AccountName_ID/file_docID.ext 🔧 Technical: - FilePathManager for standardized paths - S3StorageService integration - WebSocket server (Node.js + Docker) - Redis cache for getBasicModuleInfo() - Predis library for Redis connectivity 📝 Scripts: - Migration scripts for all modules - Test pages for WebSocket/SSE/Polling - Documentation (MIGRATION_*.md, REDIS_*.md) 🎯 Result: 15,000+ files migrated successfully!
3.6 KiB
3.6 KiB
🔧 Настройка Nginx для SSE и Redis
📋 Что нужно сделать:
1. Открыть конфигурацию Nginx:
sudo nano /etc/nginx/fastpanel2-available/fastuser/crm.clientright.ru.conf
2. Добавить ПЕРЕД строкой location / {:
# SSE endpoint для синхронизации файлов с Redis
location ~ ^/crm_extensions/file_storage/api/(sse_events|redis_sse)\.php$ {
proxy_pass http://127.0.0.1:81;
proxy_redirect http://127.0.0.1:81/ /;
# КРИТИЧЕСКИ ВАЖНО для SSE!
proxy_buffering off; # Отключаем буферизацию
proxy_cache off; # Отключаем кеш
proxy_set_header Connection ''; # HTTP/1.1 keep-alive
# Таймауты для длительных соединений
proxy_connect_timeout 3600s;
proxy_send_timeout 3600s;
proxy_read_timeout 3600s;
# Заголовки
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# HTTP/1.1 для chunked transfer encoding
proxy_http_version 1.1;
# NGINX не должен добавлять свои заголовки
add_header X-Accel-Buffering no;
}
# Long polling endpoint
location ~ ^/crm_extensions/file_storage/api/long_poll_events\.php$ {
proxy_pass http://127.0.0.1:81;
proxy_redirect http://127.0.0.1:81/ /;
# Отключаем буферизацию для long polling
proxy_buffering off;
proxy_cache off;
# Увеличенные таймауты (30 секунд для long polling)
proxy_connect_timeout 35s;
proxy_send_timeout 35s;
proxy_read_timeout 35s;
include /etc/nginx/proxy_params;
}
3. Проверить конфигурацию:
sudo nginx -t
4. Перезагрузить Nginx:
sudo systemctl reload nginx
🧪 ТЕСТИРОВАНИЕ:
После настройки Nginx:
1. Тест SSE с Redis:
# Открой в браузере:
https://crm.clientright.ru/crm_extensions/file_storage/test_redis.html
2. Тест обычного SSE:
# Открой в браузере:
https://crm.clientright.ru/crm_extensions/file_storage/test_sse_browser.html
3. Консольный тест:
curl -N https://crm.clientright.ru/crm_extensions/file_storage/api/redis_sse.php
Должен получить поток событий (не закрывается)!
📊 ЧТО ПОЛУЧИМ:
✅ SSE - мгновенные обновления (через Redis)
✅ Long Polling - надежный fallback
✅ WebSocket - уже настроен на порту 3001
✅ Polling - работает как есть (каждые 2 сек)
🎯 КАКОЙ СПОСОБ ИСПОЛЬЗОВАТЬ:
Рекомендация:
- SSE с Redis - для реального времени (мгновенно!)
- Long Polling - если SSE не работает (fallback)
- Обычный Polling - последний fallback
📝 ВАЖНО:
После добавления конфигурации:
- ✅ Проверить
nginx -t - ✅ Перезагрузить
systemctl reload nginx - ✅ Протестировать через браузер
- ✅ Проверить логи
/var/log/nginx/error.log