Files
trendyol-analiz/admin-panel/nginx.conf
furkanyigit34 c7be57064b Initial commit: Trendyol Analiz platform
- FastAPI backend with Python
- React + Vite admin panel
- PostgreSQL database
- Trendyol marketplace analytics
- GitHub Actions CI/CD workflow

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 00:14:38 +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 180s;
proxy_read_timeout 180s;
# 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;
}