You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
181 lines
6.1 KiB
181 lines
6.1 KiB
# 1. Port 80 (HTTP) Server Block - Redirect all HTTP traffic to HTTPS
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name dovodi.nwhco.ir dovodi.newhorizonco.uk dovodi.com test.dovodi.com;
|
|
|
|
# Immediate 301 redirect to HTTPS without caching redirect
|
|
location / {
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
}
|
|
|
|
# 2. Port 443 (HTTPS) Server Block
|
|
server {
|
|
listen 443 ssl http2;
|
|
listen [::]:443 ssl http2;
|
|
server_name dovodi.nwhco.ir dovodi.newhorizonco.uk dovodi.com test.dovodi.com;
|
|
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 $http_x_forwarded_proto;
|
|
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 $http_x_forwarded_proto;
|
|
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 $http_x_forwarded_proto;
|
|
client_max_body_size 1200M;
|
|
}
|
|
|
|
# ========== Admin Entry Points ==========
|
|
# Now using domain-based routing, /admin/ goes directly to Django
|
|
# Django middleware will route to the correct admin panel based on domain
|
|
|
|
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 $http_x_forwarded_proto;
|
|
client_max_body_size 1200M;
|
|
}
|
|
|
|
# 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 X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
|
|
client_max_body_size 1200M;
|
|
}
|
|
|
|
location /agent/ {
|
|
proxy_pass http://88.99.212.243:8098;
|
|
proxy_http_version 1.1;
|
|
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 $http_x_forwarded_proto;
|
|
proxy_set_header Authorization $http_authorization;
|
|
proxy_pass_header Authorization;
|
|
client_max_body_size 500M;
|
|
proxy_read_timeout 600s;
|
|
proxy_send_timeout 600s;
|
|
}
|
|
|
|
# ========== 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 $http_x_forwarded_proto;
|
|
|
|
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_staticfiles/;
|
|
expires 30d;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
location /media/ {
|
|
alias /home/app/web/imam_javad_mediafiles/;
|
|
|
|
# Range Requests for audio streaming / seeking in player
|
|
add_header Accept-Ranges bytes;
|
|
|
|
# CORS headers for media streaming
|
|
add_header Access-Control-Allow-Origin * always;
|
|
add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS' always;
|
|
add_header Access-Control-Allow-Headers 'Range, Origin, Content-Type, Accept' always;
|
|
|
|
# Standard static cache
|
|
expires 30d;
|
|
add_header Cache-Control "public, no-transform";
|
|
|
|
access_log off;
|
|
log_not_found off;
|
|
}
|
|
|
|
# ========== 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 / {
|
|
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;
|
|
}
|
|
}
|