|
|
@ -1,41 +1,19 @@ |
|
|
# ======================================== |
|
|
# ======================================== |
|
|
# Imam Javad Platform - Nginx Configuration |
|
|
# Imam Javad Platform - Nginx Configuration |
|
|
# Single Domain - Clean Architecture |
|
|
|
|
|
|
|
|
# Multi-Domain Architecture (Standardized with Dovoodi) |
|
|
# ======================================== |
|
|
# ======================================== |
|
|
|
|
|
|
|
|
# ========== Upstream Definitions ========== |
|
|
|
|
|
upstream django_backend { |
|
|
|
|
|
server 88.99.212.243:8010; |
|
|
|
|
|
keepalive 32; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
upstream nextjs_frontend { |
|
|
|
|
|
server 88.99.212.243:7226; |
|
|
|
|
|
keepalive 32; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
upstream panel_frontend { |
|
|
|
|
|
server 88.99.212.243:7228; |
|
|
|
|
|
keepalive 16; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
upstream chat_service { |
|
|
|
|
|
server 88.99.212.243:8020; |
|
|
|
|
|
keepalive 32; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# ========== Proxy Settings (Reusable) ========== |
|
|
|
|
|
# Include this file or copy these settings |
|
|
|
|
|
# /etc/nginx/snippets/proxy-params.conf |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ======================================== |
|
|
|
|
|
# 1. MAIN WEBSITE SERVER BLOCK |
|
|
|
|
|
# ======================================== |
|
|
server { |
|
|
server { |
|
|
listen 80; |
|
|
listen 80; |
|
|
listen 443 ssl; |
|
|
listen 443 ssl; |
|
|
server_name imamjavad.nwhco.ir imamjavad.newhorizonco.uk; |
|
|
|
|
|
|
|
|
|
|
|
# ssl_certificate /etc/nginx/certs/nwhco.pem; |
|
|
|
|
|
# ssl_certificate_key /etc/nginx/certs/nwhco.key; |
|
|
|
|
|
# include /etc/nginx/options-ssl-nginx.conf; |
|
|
|
|
|
|
|
|
server_name imamjavad.online imamjavad.nwhco.ir imamjavad.newhorizonco.uk; |
|
|
|
|
|
|
|
|
|
|
|
ssl_certificate /etc/nginx/certs/nwhco.pem; |
|
|
|
|
|
ssl_certificate_key /etc/nginx/certs/nwhco.key; |
|
|
|
|
|
include /etc/nginx/options-ssl-nginx.conf; |
|
|
|
|
|
|
|
|
# ========== Global Settings ========== |
|
|
# ========== Global Settings ========== |
|
|
client_max_body_size 500M; |
|
|
client_max_body_size 500M; |
|
|
@ -45,52 +23,73 @@ server { |
|
|
proxy_send_timeout 600s; |
|
|
proxy_send_timeout 600s; |
|
|
proxy_read_timeout 600s; |
|
|
proxy_read_timeout 600s; |
|
|
|
|
|
|
|
|
# ========== 1. Static Files (Highest Priority) ========== |
|
|
|
|
|
location /static/ { |
|
|
|
|
|
alias /home/app/web/imam_javad_staticfiles/; |
|
|
|
|
|
expires 30d; |
|
|
|
|
|
add_header Cache-Control "public, immutable"; |
|
|
|
|
|
access_log off; |
|
|
|
|
|
|
|
|
# ========== Django App Paths (Must be before location /) ========== |
|
|
|
|
|
|
|
|
|
|
|
# با prefix زبانی |
|
|
|
|
|
location /en/imam-javad/ { |
|
|
|
|
|
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 /media/ { |
|
|
|
|
|
alias /home/app/web/imam_javad_mediafiles/; |
|
|
|
|
|
expires 30d; |
|
|
|
|
|
add_header Cache-Control "public, immutable"; |
|
|
|
|
|
add_header Access-Control-Allow-Origin *; |
|
|
|
|
|
add_header Access-Control-Allow-Methods "GET, OPTIONS"; |
|
|
|
|
|
access_log off; |
|
|
|
|
|
|
|
|
location /fa/imam-javad/ { |
|
|
|
|
|
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; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# ========== 2. Next.js Assets ========== |
|
|
|
|
|
location /_next/ { |
|
|
|
|
|
proxy_pass http://nextjs_frontend; |
|
|
|
|
|
proxy_http_version 1.1; |
|
|
|
|
|
|
|
|
# بدون prefix زبانی (fallback) |
|
|
|
|
|
location /imam-javad/ { |
|
|
|
|
|
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 Host $host; |
|
|
proxy_set_header X-Real-IP $remote_addr; |
|
|
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/ { |
|
|
|
|
|
proxy_pass http://88.99.212.243:8010; |
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
|
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; |
|
|
proxy_set_header X-Forwarded-Proto $scheme; |
|
|
expires 1y; |
|
|
|
|
|
add_header Cache-Control "public, immutable"; |
|
|
|
|
|
access_log off; |
|
|
|
|
|
|
|
|
client_max_body_size 1200M; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# ========== 3. API Endpoints ========== |
|
|
|
|
|
location /api/ { |
|
|
|
|
|
proxy_pass http://django_backend; |
|
|
|
|
|
proxy_http_version 1.1; |
|
|
|
|
|
|
|
|
# Handle /en/admin/ and /fa/admin/ (Django i18n redirects) |
|
|
|
|
|
location ~ ^/(en|fa)/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 Host $host; |
|
|
proxy_set_header X-Real-IP $remote_addr; |
|
|
proxy_set_header X-Real-IP $remote_addr; |
|
|
|
|
|
proxy_set_header X-Forwarded-Proto $scheme; |
|
|
|
|
|
client_max_body_size 1200M; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# ========== Django Services (API & Chat) ========== |
|
|
|
|
|
location /api { |
|
|
|
|
|
proxy_pass http://88.99.212.243:8010; |
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
|
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; |
|
|
proxy_set_header X-Forwarded-Proto $scheme; |
|
|
proxy_set_header Authorization $http_authorization; |
|
|
proxy_set_header Authorization $http_authorization; |
|
|
proxy_pass_header Authorization; |
|
|
proxy_pass_header Authorization; |
|
|
client_max_body_size 1200M; |
|
|
client_max_body_size 1200M; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# ========== 4. Chat Service (WebSocket) ========== |
|
|
|
|
|
location /chat { |
|
|
location /chat { |
|
|
proxy_pass http://chat_service; |
|
|
|
|
|
|
|
|
proxy_pass http://88.99.212.243:8020; |
|
|
proxy_http_version 1.1; |
|
|
proxy_http_version 1.1; |
|
|
proxy_set_header Upgrade $http_upgrade; |
|
|
proxy_set_header Upgrade $http_upgrade; |
|
|
proxy_set_header Connection "upgrade"; |
|
|
proxy_set_header Connection "upgrade"; |
|
|
@ -98,25 +97,32 @@ server { |
|
|
proxy_set_header X-Real-IP $remote_addr; |
|
|
proxy_set_header X-Real-IP $remote_addr; |
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
|
client_max_body_size 1200M; |
|
|
client_max_body_size 1200M; |
|
|
|
|
|
|
|
|
# WebSocket timeouts |
|
|
|
|
|
proxy_read_timeout 3600s; |
|
|
proxy_read_timeout 3600s; |
|
|
proxy_send_timeout 3600s; |
|
|
proxy_send_timeout 3600s; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# ========== 5. i18n Language Switcher ========== |
|
|
|
|
|
location /i18n/ { |
|
|
|
|
|
proxy_pass http://django_backend; |
|
|
|
|
|
|
|
|
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 Host $host; |
|
|
proxy_set_header X-Real-IP $remote_addr; |
|
|
|
|
|
|
|
|
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 X-Forwarded-For $proxy_add_x_forwarded_for; |
|
|
proxy_set_header X-Forwarded-Proto $scheme; |
|
|
|
|
|
|
|
|
proxy_set_header Host $host; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# ========== 6. Django Admin Panel (Single Pattern) ========== |
|
|
|
|
|
# Matches: /en/imam-javad/admin/, /fa/imam-javad/admin/, /imam-javad/admin/ |
|
|
|
|
|
location ~ ^/(en|fa)?/?imam-javad/ { |
|
|
|
|
|
proxy_pass http://django_backend; |
|
|
|
|
|
|
|
|
location /filer/ { |
|
|
|
|
|
proxy_pass http://88.99.212.243:8010; |
|
|
proxy_http_version 1.1; |
|
|
proxy_http_version 1.1; |
|
|
proxy_set_header Host $host; |
|
|
proxy_set_header Host $host; |
|
|
proxy_set_header X-Real-IP $remote_addr; |
|
|
proxy_set_header X-Real-IP $remote_addr; |
|
|
@ -125,35 +131,65 @@ server { |
|
|
client_max_body_size 1200M; |
|
|
client_max_body_size 1200M; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# ========== 7. Dovoodi Admin Panel (Single Pattern) ========== |
|
|
|
|
|
# Matches: /en/dovoodi/admin/, /fa/dovoodi/admin/, /dovoodi/admin/ |
|
|
|
|
|
location ~ ^/(en|fa)?/?dovoodi/ { |
|
|
|
|
|
proxy_pass http://django_backend; |
|
|
|
|
|
proxy_http_version 1.1; |
|
|
|
|
|
|
|
|
# ========== Static & Media Files ========== |
|
|
|
|
|
location /static/ { |
|
|
|
|
|
alias /home/app/web/imam_javad_staticfiles/; |
|
|
|
|
|
expires 30d; |
|
|
|
|
|
add_header Cache-Control "public, immutable"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
location /media/ { |
|
|
|
|
|
alias /home/app/web/imam_javad_mediafiles/; |
|
|
|
|
|
expires 30d; |
|
|
|
|
|
add_header Cache-Control "public, immutable"; |
|
|
|
|
|
add_header Access-Control-Allow-Origin *; |
|
|
|
|
|
add_header Access-Control-Allow-Methods "GET, OPTIONS"; |
|
|
|
|
|
add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# ========== Next.js Frontend ========== |
|
|
|
|
|
location /_next/ { |
|
|
|
|
|
# پورت فرانتاند امام جواد 7226 است |
|
|
|
|
|
proxy_pass http://88.99.212.243:7226/_next/; |
|
|
proxy_set_header Host $host; |
|
|
proxy_set_header Host $host; |
|
|
proxy_set_header X-Real-IP $remote_addr; |
|
|
proxy_set_header X-Real-IP $remote_addr; |
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
|
proxy_set_header X-Forwarded-Proto $scheme; |
|
|
proxy_set_header X-Forwarded-Proto $scheme; |
|
|
client_max_body_size 1200M; |
|
|
|
|
|
|
|
|
expires 1y; |
|
|
|
|
|
add_header Cache-Control "public, immutable"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# ========== 8. Swagger & API Documentation ========== |
|
|
|
|
|
# Matches: /en/swagger/, /fa/swagger/, /en/redoc/, /fa/redoc/, /en/docs/ |
|
|
|
|
|
location ~ ^/(en|fa)/(swagger|redoc|docs) { |
|
|
|
|
|
proxy_pass http://django_backend; |
|
|
|
|
|
proxy_http_version 1.1; |
|
|
|
|
|
|
|
|
location / { |
|
|
|
|
|
proxy_pass http://88.99.212.243:7226; |
|
|
|
|
|
client_max_body_size 1200M; |
|
|
|
|
|
proxy_set_header Upgrade $http_upgrade; |
|
|
|
|
|
proxy_set_header Connection "upgrade"; |
|
|
proxy_set_header Host $host; |
|
|
proxy_set_header Host $host; |
|
|
proxy_set_header X-Real-IP $remote_addr; |
|
|
proxy_set_header X-Real-IP $remote_addr; |
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
|
proxy_set_header X-Forwarded-Proto $scheme; |
|
|
|
|
|
proxy_set_header Authorization $http_authorization; |
|
|
|
|
|
proxy_pass_header Authorization; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
# ========== 9. Filer (Django File Manager) ========== |
|
|
|
|
|
location /filer/ { |
|
|
|
|
|
proxy_pass http://django_backend; |
|
|
|
|
|
proxy_http_version 1.1; |
|
|
|
|
|
|
|
|
# ======================================== |
|
|
|
|
|
# 2. DASHBOARD (SUBDOMAIN) SERVER BLOCK |
|
|
|
|
|
# ======================================== |
|
|
|
|
|
server { |
|
|
|
|
|
listen 80; |
|
|
|
|
|
listen 443 ssl; |
|
|
|
|
|
|
|
|
|
|
|
server_name dashboard.imamjavad.online; |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
proxy_connect_timeout 600s; |
|
|
|
|
|
proxy_send_timeout 600s; |
|
|
|
|
|
proxy_read_timeout 600s; |
|
|
|
|
|
|
|
|
|
|
|
location /api/ { |
|
|
|
|
|
proxy_pass http://88.99.212.243:8010; |
|
|
proxy_set_header Host $host; |
|
|
proxy_set_header Host $host; |
|
|
proxy_set_header X-Real-IP $remote_addr; |
|
|
proxy_set_header X-Real-IP $remote_addr; |
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
|
@ -161,41 +197,27 @@ server { |
|
|
client_max_body_size 1200M; |
|
|
client_max_body_size 1200M; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# ========== 10. Admin Entry Point Redirect ========== |
|
|
|
|
|
# /admin → /en/imam-javad/admin/ |
|
|
|
|
|
location = /admin { |
|
|
|
|
|
return 301 /en/imam-javad/admin/; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
location = /admin/ { |
|
|
|
|
|
return 301 /en/imam-javad/admin/; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# ========== 11. Admin Panel (React/Vite) ========== |
|
|
|
|
|
# Served at /panel/ — internal Nginx handles SPA routing |
|
|
|
|
|
location /panel/ { |
|
|
|
|
|
proxy_pass http://panel_frontend; |
|
|
|
|
|
|
|
|
# پورت پنل فرانتاند امام جواد 7228 است |
|
|
|
|
|
location / { |
|
|
|
|
|
proxy_pass http://88.99.212.243:7228; |
|
|
proxy_http_version 1.1; |
|
|
proxy_http_version 1.1; |
|
|
proxy_set_header Host $host; |
|
|
proxy_set_header Host $host; |
|
|
proxy_set_header X-Real-IP $remote_addr; |
|
|
proxy_set_header X-Real-IP $remote_addr; |
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
|
proxy_set_header X-Forwarded-Proto $scheme; |
|
|
proxy_set_header X-Forwarded-Proto $scheme; |
|
|
|
|
|
proxy_set_header Upgrade $http_upgrade; |
|
|
|
|
|
proxy_set_header Connection "upgrade"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# Redirect /panel → /panel/ (trailing slash matters for base path) |
|
|
|
|
|
location = /panel { |
|
|
|
|
|
return 301 /panel/; |
|
|
|
|
|
|
|
|
location /static/ { |
|
|
|
|
|
alias /home/app/web/imam_javad_staticfiles/; |
|
|
|
|
|
expires 30d; |
|
|
|
|
|
add_header Cache-Control "public, immutable"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# ========== 12. Next.js Frontend (Catch-all - Lowest Priority) ========== |
|
|
|
|
|
location / { |
|
|
|
|
|
proxy_pass http://nextjs_frontend; |
|
|
|
|
|
proxy_http_version 1.1; |
|
|
|
|
|
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; |
|
|
|
|
|
proxy_set_header X-Forwarded-Proto $scheme; |
|
|
|
|
|
|
|
|
location /media/ { |
|
|
|
|
|
alias /home/app/web/imam_javad_mediafiles/; |
|
|
|
|
|
expires 30d; |
|
|
|
|
|
add_header Access-Control-Allow-Origin *; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |