server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; client_max_body_size 15m; # PM روی همان دامنه ERP زیر پیشوند /pm سرو می‌شود (پنل «مدیریت پروژه»). # پروکسی API به بک‌اند PM — هم زیر /pm/api (ادغام با ERP) هم /api (دسترسی مستقیم) location /pm/api/ { proxy_pass http://pm-api:8000/api/; 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; } location /api/ { proxy_pass http://pm-api:8000; 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; } # SPA زیر /pm/ — نقطه ورود پنل «مدیریت پروژه» روی دامنه ERP location /pm/ { alias /usr/share/nginx/html/; try_files $uri $uri/ /pm/index.html; } location = /pm { return 301 /pm/; } location = /pm/index.html { add_header Cache-Control "no-cache, no-store, must-revalidate"; alias /usr/share/nginx/html/index.html; } # SPA fallback (دسترسی مستقیم به فرانت PM بدون پیشوند) location / { try_files $uri $uri/ /index.html; } # index.html همیشه بدون کش location = /index.html { add_header Cache-Control "no-cache, no-store, must-revalidate"; try_files $uri =404; } # فایل‌های استاتیک هش‌دار با کش بلندمدت location /assets/ { add_header Cache-Control "public, max-age=31536000, immutable"; try_files $uri =404; } }