nakama/nginx-moderation-production...

113 lines
3.6 KiB
Plaintext
Raw Normal View History

2025-12-08 23:42:32 +00:00
# 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;
# Логи
access_log /var/log/nginx/moderation-access.log;
error_log /var/log/nginx/moderation-error.log;
# Максимальный размер загружаемых файлов
client_max_body_size 20M;
# 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 запросов к бэкенду модерации
location /api {
proxy_pass http://nakama-moderation-backend: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 $scheme;
proxy_set_header X-Forwarded-Host $host;
# WebSocket поддержка
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Таймауты
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
# WebSocket для чата модераторов
location /mod-chat {
proxy_pass http://nakama-moderation-backend:3001;
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;
# Таймауты для WebSocket
proxy_connect_timeout 7d;
proxy_send_timeout 7d;
proxy_read_timeout 7d;
}
# Статические файлы фронтенда (из Docker контейнера)
location / {
proxy_pass http://nakama-moderation-frontend:80;
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 $scheme;
# Кэширование статических файлов
proxy_cache_valid 200 1y;
proxy_cache_valid 404 1h;
}
}