server { listen 80; # listen 443 ssl; server_name dovodi.newhorizonco.uk dovoodi.newhorizonco.uk; # ssl_certificate /etc/nginx/certs/nwhco.pem; # ssl_certificate_key /etc/nginx/certs/nwhco.key; # include /etc/nginx/options-ssl-nginx.conf; client_max_body_size 500M; client_body_timeout 600s; client_header_timeout 60s; proxy_connect_timeout 600s; proxy_send_timeout 600s; proxy_read_timeout 600s; # ========== Django Admin Paths (باید قبل از location / باشند) ========== # با prefix زبانی location /en/dovoodi/ { proxy_pass http://88.99.212.243:8010; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; client_max_body_size 1200M; } location /fa/dovoodi/ { proxy_pass http://88.99.212.243:8010; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; client_max_body_size 1200M; } # بدون prefix زبانی (fallback) location /dovoodi/ { proxy_pass http://88.99.212.243:8010; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; client_max_body_size 1200M; } # ========== Admin Entry Points ========== location = /admin { return 301 /admin/; } location /admin/ { proxy_pass http://88.99.212.243:8010; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; client_max_body_size 1200M; } location = /admin/logout { return 301 /en/dovoodi/admin/logout/; } # مسیر عمومی admin (سازگاری با config قدیمی) location /en/admin { proxy_pass http://88.99.212.243:8010; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; client_max_body_size 1200M; } # ========== Django Services ========== location /api { proxy_pass http://88.99.212.243:8010; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_method $request_method; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; # 🔥 CRITICAL: Forward Authorization header for Token authentication proxy_set_header Authorization $http_authorization; proxy_pass_header Authorization; client_max_body_size 1200M; } location /en/swagger { proxy_pass http://88.99.212.243:8010; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_set_header Authorization $http_authorization; proxy_pass_header Authorization; } location /en/redoc { proxy_pass http://88.99.212.243:8010; proxy_set_header Authorization $http_authorization; proxy_pass_header Authorization; } location /i18n/ { proxy_pass http://88.99.212.243:8010; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; } # ========== Static & Media Files ========== location /static/ { alias /home/app/web/imam_javad_static/static/; } location /media/ { alias /home/app/web/imam_javad_static/media/; } # ========== Next.js Frontend ========== location /_next/ { proxy_pass http://88.99.212.243:7227/_next/; 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; expires 1y; add_header Cache-Control "public, immutable"; } # ⚠️ این باید آخرین location باشد (fallback) location / { proxy_pass http://88.99.212.243:7227; client_max_body_size 1200M; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }