121 lines
5.5 KiB
Plaintext
121 lines
5.5 KiB
Plaintext
# ============================================================
|
||
# nginx — production config для test.cloud-copp74.ru
|
||
# Устанавливается на отдельном nginx-сервере с certbot.
|
||
#
|
||
# Замените APP_IP на внутренний IP сервера с Docker.
|
||
#
|
||
# Первый запуск (получение сертификата):
|
||
# 1. Разместите этот файл в /etc/nginx/sites-available/copp
|
||
# 2. Создайте симлинк: ln -s /etc/nginx/sites-available/copp /etc/nginx/sites-enabled/
|
||
# 3. Временно раскомментируйте блок certbot-challenge (см. ниже)
|
||
# 4. nginx -t && systemctl reload nginx
|
||
# 5. certbot --nginx -d test.cloud-copp74.ru
|
||
# 6. certbot создаст ssl-блок автоматически или используйте конфиг ниже
|
||
# ============================================================
|
||
|
||
# Сервер приложения
|
||
upstream flet_app {
|
||
server 192.168.1.18:80;
|
||
keepalive 32;
|
||
}
|
||
|
||
# ── HTTP → HTTPS редирект ────────────────────────────────────
|
||
server {
|
||
listen 80;
|
||
listen [::]:80;
|
||
server_name test.cloud-copp74.ru;
|
||
|
||
# certbot challenge (оставьте всегда, certbot сам обновляет сертификат)
|
||
location /.well-known/acme-challenge/ {
|
||
root /var/www/certbot;
|
||
}
|
||
|
||
location / {
|
||
return 301 https://$host$request_uri;
|
||
}
|
||
}
|
||
|
||
# ── HTTPS ────────────────────────────────────────────────────
|
||
server {
|
||
listen 443 ssl http2;
|
||
listen [::]:443 ssl http2;
|
||
server_name test.cloud-copp74.ru;
|
||
|
||
# Сертификаты Let's Encrypt (certbot заполнит сам, или укажите вручную)
|
||
ssl_certificate /etc/letsencrypt/live/test.cloud-copp74.ru/fullchain.pem;
|
||
ssl_certificate_key /etc/letsencrypt/live/test.cloud-copp74.ru/privkey.pem;
|
||
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
||
|
||
# ── Безопасность ────────────────────────────────────────
|
||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||
add_header X-Frame-Options SAMEORIGIN always;
|
||
add_header X-Content-Type-Options nosniff always;
|
||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||
|
||
# ── Производительность ──────────────────────────────────
|
||
gzip on;
|
||
gzip_types text/plain text/css application/javascript application/json image/svg+xml;
|
||
gzip_min_length 1024;
|
||
gzip_comp_level 5;
|
||
gzip_vary on;
|
||
|
||
client_max_body_size 16m;
|
||
|
||
# ── WebSocket (Flet) ────────────────────────────────────
|
||
# Flet держит постоянное WS-соединение на /ws
|
||
location /ws {
|
||
proxy_pass http://flet_app;
|
||
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;
|
||
|
||
# Долгоживущие WS-соединения — не рвать
|
||
proxy_read_timeout 3600s;
|
||
proxy_send_timeout 3600s;
|
||
proxy_connect_timeout 10s;
|
||
}
|
||
|
||
# ── Статика Flet (assets, иконки) ───────────────────────
|
||
location ~* \.(js|css|woff2?|svg|png|jpg|ico|webp)$ {
|
||
proxy_pass http://flet_app;
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Forwarded-Proto $scheme;
|
||
|
||
# Кешируем статику на клиенте 7 дней
|
||
expires 7d;
|
||
add_header Cache-Control "public, immutable";
|
||
access_log off;
|
||
}
|
||
|
||
# ── SVG диаграмма (radar-image) ─────────────────────────
|
||
location /radar-image/ {
|
||
proxy_pass http://flet_app;
|
||
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_read_timeout 30s;
|
||
}
|
||
|
||
# ── Всё остальное → Flet app ────────────────────────────
|
||
location / {
|
||
proxy_pass http://flet_app;
|
||
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 Connection "";
|
||
|
||
proxy_connect_timeout 10s;
|
||
proxy_read_timeout 60s;
|
||
proxy_send_timeout 60s;
|
||
}
|
||
}
|