135 lines
4.5 KiB
Plaintext
135 lines
4.5 KiB
Plaintext
# HTTP -> HTTPS редирект
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name moderation.nkm.guru;
|
|
|
|
# Let's Encrypt challenge
|
|
location /.well-known/acme-challenge/ {
|
|
root /var/www/certbot;
|
|
}
|
|
|
|
location / {
|
|
return 301 https://$server_name$request_uri;
|
|
}
|
|
}
|
|
|
|
# HTTPS сервер
|
|
server {
|
|
listen 443 ssl http2;
|
|
listen [::]:443 ssl http2;
|
|
server_name moderation.nkm.guru;
|
|
|
|
# SSL сертификаты (Let's Encrypt)
|
|
ssl_certificate /etc/letsencrypt/live/moderation.nkm.guru/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/moderation.nkm.guru/privkey.pem;
|
|
|
|
# SSL настройки
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_ciphers HIGH:!aNULL:!MD5;
|
|
ssl_prefer_server_ciphers on;
|
|
ssl_session_cache shared:SSL:10m;
|
|
ssl_session_timeout 10m;
|
|
|
|
# Security headers
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header X-XSS-Protection "1; mode=block" always;
|
|
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
|
|
# Логи
|
|
access_log /var/log/nginx/moderation-access.log;
|
|
error_log /var/log/nginx/moderation-error.log;
|
|
|
|
# Максимальный размер загружаемых файлов
|
|
client_max_body_size 20M;
|
|
|
|
# Корневая директория фронтенда
|
|
root /var/www/nakama/moderation/frontend/dist;
|
|
index index.html;
|
|
|
|
# Gzip compression
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_min_length 1024;
|
|
gzip_proxied any;
|
|
gzip_comp_level 6;
|
|
gzip_types text/plain text/css text/xml text/javascript
|
|
application/json application/javascript application/xml+rss
|
|
application/rss+xml font/truetype font/opentype
|
|
application/vnd.ms-fontobject image/svg+xml;
|
|
|
|
# Проксирование API запросов к бэкенду модерации
|
|
# ИЗМЕНИТЕ localhost:3001 на ваш реальный адрес бэкенда
|
|
location /api {
|
|
proxy_pass http://127.0.0.1:3001;
|
|
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 https; # Всегда HTTPS
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
proxy_set_header X-Forwarded-Port 443;
|
|
|
|
# WebSocket поддержка
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
# Таймауты
|
|
proxy_connect_timeout 60s;
|
|
proxy_send_timeout 60s;
|
|
proxy_read_timeout 60s;
|
|
|
|
# Отключить буферизацию для реального времени
|
|
proxy_buffering off;
|
|
}
|
|
|
|
# WebSocket для Socket.IO (чат модераторов)
|
|
# ВАЖНО: location должен быть без trailing slash для Socket.IO
|
|
location /socket.io {
|
|
proxy_pass http://127.0.0.1:3001;
|
|
proxy_http_version 1.1;
|
|
|
|
# WebSocket upgrade headers
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
# Standard proxy headers
|
|
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 https; # Всегда HTTPS
|
|
proxy_set_header X-Forwarded-Port 443;
|
|
|
|
# Таймауты для WebSocket
|
|
proxy_connect_timeout 7d;
|
|
proxy_send_timeout 7d;
|
|
proxy_read_timeout 7d;
|
|
|
|
# Отключить буферизацию для real-time
|
|
proxy_buffering off;
|
|
proxy_request_buffering off;
|
|
}
|
|
|
|
# Статические файлы фронтенда
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# Кэширование статических файлов
|
|
location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot|map)$ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
access_log off;
|
|
}
|
|
|
|
# Без кэша для index.html (для обновлений)
|
|
location = /index.html {
|
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
add_header Pragma "no-cache";
|
|
add_header Expires "0";
|
|
}
|
|
}
|