Files
cactoz.su/nginx/nginx.conf
T
cacto 5e99bc8c45 Убрать версию nginx из заголовка Server
server_tokens off — не отдаём точный номер версии наружу, мелкое
затруднение для разведки перед атакой на известные CVE.
2026-08-12 00:33:07 +05:00

43 lines
1.8 KiB
Nginx Configuration File

# на IP: не более 5 новых /ws соединений в секунду, всплеск до 10 без задержки
limit_req_zone $binary_remote_addr zone=ws_connect:10m rate=5r/s;
# на IP: не более 20 одновременных /ws соединений — не даёт одному клиенту
# открыть тысячи сокетов и завалить lobby.create_room комнатами до OOM
limit_conn_zone $binary_remote_addr zone=ws_conn:10m;
server {
listen 80;
server_name cactoz.su www.cactoz.su;
root /usr/share/nginx/html;
index index.html;
# не светим точную версию nginx в заголовке Server и в error-страницах
server_tokens off;
add_header X-Content-Type-Options nosniff always;
add_header X-Frame-Options DENY always;
add_header Referrer-Policy strict-origin-when-cross-origin always;
add_header Content-Security-Policy "default-src 'self'; connect-src 'self' wss://cactoz.su wss://www.cactoz.su; img-src 'self' data:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; base-uri 'none'; frame-ancestors 'none'" always;
location / {
try_files $uri $uri.html $uri/ =404;
}
# без хешей в именах файлов — просим браузер всегда переспрашивать свежесть
location ~* \.(js|css)$ {
add_header Cache-Control "no-cache";
try_files $uri =404;
}
location /ws {
limit_req zone=ws_connect burst=10 nodelay;
limit_conn ws_conn 20;
proxy_pass http://gameserver:9001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_read_timeout 3600s;
}
}