Files
trendyol-analiz/admin-panel/nginx.conf
furkanyigit34 dc1f8fcfb2 fix: SSE timeout during social proof collection
Ne yaptık:
- time.sleep() → await asyncio.sleep() ile event loop bloklanması engellendi
- Sosyal kanıt batch size 5 → 20 (1115 istek → 279 istek, %75 azalma)
- SSE keepalive heartbeat eklendi (her 10 batch'te bir)
- Nginx proxy timeout 180s → 600s (10 dakika)
- Rate limit sleep süreleri optimize edildi (2s→1.5s, 0.5s→0.3s)

Neden yaptık:
- Kadın kategorisi gibi büyük raporlarda (82 yaprak kategori, 5576 ürün)
  sosyal kanıt aşamasında SSE bağlantısı kopuyordu. Kök neden:
  senkron time.sleep() async generator içinde event loop'u blokluyor,
  proxy idle timeout'a takılıyor ve bağlantıyı kesiyordu.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 17:01:14 +03:00

81 lines
2.4 KiB
Nginx Configuration File

# Nginx configuration for React SPA + FastAPI backend proxy
# Optimized for production deployment with gzip compression and caching
server {
listen 80;
server_name _;
# Root directory for static files
root /usr/share/nginx/html;
index index.html;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
# Gzip compression for performance
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript
application/x-javascript application/xml+rss
application/javascript application/json
application/xml image/svg+xml;
# API proxy to backend service
# All requests to /api/* are proxied to the backend container
location /api/ {
proxy_pass http://backend:8001;
proxy_http_version 1.1;
# Preserve original request information
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;
# Timeouts for long-running operations
proxy_connect_timeout 60s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
# Disable buffering for streaming responses
proxy_buffering off;
proxy_request_buffering off;
}
# Static assets caching (JS, CSS, images, fonts)
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
access_log off;
}
# React Router - SPA fallback routing
# All non-file requests return index.html for client-side routing
location / {
try_files $uri $uri/ /index.html;
# No caching for index.html (always fetch latest)
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
}
# Health check endpoint (for Coolify/Docker monitoring)
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
# Error pages
error_page 404 /index.html;
error_page 500 502 503 504 /index.html;
# Logging
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log warn;
}