canina/nginx.conf
2026-08-08 17:46:42 +03:30

93 lines
2.7 KiB
Nginx Configuration File

server {
listen 8080;
server_name canina.ir stage.canina.ir;
# 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;
# Block SEO Indexing for Staging Environment
if ($host = "stage.canina.ir") {
add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive" always;
}
# Main Application (Next.js)
location / {
# Basic Authentication for Staging Environment
if ($host = "stage.canina.ir") {
set $auth_type "Staging Restricted Area";
}
if ($host != "stage.canina.ir") {
set $auth_type "off";
}
auth_basic $auth_type;
auth_basic_user_file /etc/nginx/.htpasswd;
proxy_pass http://localhost: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;
}
# Backend API
location /api {
proxy_pass http://backend: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;
client_max_body_size 50M;
}
}
server {
listen 8080;
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;
# Block SEO Indexing for Staging Admin
if ($host = "stageadmin.canina.ir") {
add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive" always;
}
# SPA routing for Admin Panel
location / {
if ($host = "stageadmin.canina.ir") {
set $auth_type "Staging Admin Restricted Area";
}
if ($host != "stageadmin.canina.ir") {
set $auth_type "off";
}
auth_basic $auth_type;
auth_basic_user_file /etc/nginx/.htpasswd;
try_files $uri $uri/ /index.html;
}
# Backend API for Admin
location /api {
proxy_pass http://backend: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;
client_max_body_size 50M;
}
}