104 lines
3.2 KiB
Nginx Configuration File
104 lines
3.2 KiB
Nginx Configuration File
server {
|
|
listen 8080;
|
|
# Docker service IPs change on recreation; resolve at request time, not startup.
|
|
resolver 127.0.0.11 valid=5s ipv6=off;
|
|
resolver_timeout 2s;
|
|
set $backend_upstream __BACKEND_HOST__:3000;
|
|
server_name canina.ir stage.canina.ir localhost;
|
|
|
|
# Security Headers
|
|
server_tokens off;
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header X-XSS-Protection "1; mode=block" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
|
|
|
# Force robots.txt block for staging domains
|
|
location = /robots.txt {
|
|
if ($host ~* 'stage') {
|
|
return 200 "User-agent: *\nDisallow: /\n";
|
|
}
|
|
proxy_pass http://127.0.0.1:3000;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
}
|
|
|
|
# Main Application (Next.js)
|
|
location / {
|
|
proxy_pass http://127.0.0.1:3000;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection 'upgrade';
|
|
proxy_set_header Host $host;
|
|
proxy_cache_bypass $http_upgrade;
|
|
}
|
|
|
|
# Uploads Static Files
|
|
location /uploads {
|
|
proxy_pass http://$backend_upstream;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection 'upgrade';
|
|
proxy_set_header Host $host;
|
|
proxy_cache_bypass $http_upgrade;
|
|
client_max_body_size 50M;
|
|
}
|
|
|
|
# Backend API
|
|
location /api {
|
|
proxy_pass http://$backend_upstream;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection 'upgrade';
|
|
proxy_set_header Host $host;
|
|
proxy_cache_bypass $http_upgrade;
|
|
client_max_body_size 50M;
|
|
}
|
|
}
|
|
|
|
server {
|
|
listen 8080;
|
|
# Docker service IPs change on recreation; resolve at request time, not startup.
|
|
resolver 127.0.0.11 valid=5s ipv6=off;
|
|
resolver_timeout 2s;
|
|
set $backend_upstream __BACKEND_HOST__:3000;
|
|
server_name admin.canina.ir stageadmin.canina.ir;
|
|
|
|
root /app/admin_static;
|
|
index index.html;
|
|
|
|
# Security Headers
|
|
server_tokens off;
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header X-XSS-Protection "1; mode=block" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
|
|
|
# SPA routing for Admin Panel
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# Uploads Static Files for Admin
|
|
location /uploads {
|
|
proxy_pass http://$backend_upstream;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection 'upgrade';
|
|
proxy_set_header Host $host;
|
|
proxy_cache_bypass $http_upgrade;
|
|
client_max_body_size 50M;
|
|
}
|
|
|
|
# Backend API for Admin
|
|
location /api {
|
|
proxy_pass http://$backend_upstream;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection 'upgrade';
|
|
proxy_set_header Host $host;
|
|
proxy_cache_bypass $http_upgrade;
|
|
client_max_body_size 50M;
|
|
}
|
|
}
|