80 lines
3.0 KiB
Nginx Configuration File
80 lines
3.0 KiB
Nginx Configuration File
# Конфигурация для внешнего nginx сервера с Let's Encrypt
|
||
# Поместите этот файл в /etc/nginx/sites-available/cooperative-app
|
||
|
||
# Редирект HTTP на HTTPS
|
||
server {
|
||
listen 80;
|
||
server_name your-domain.com; # Замените на ваш домен
|
||
|
||
# Для Let's Encrypt ACME challenge
|
||
location /.well-known/acme-challenge/ {
|
||
root /var/www/certbot;
|
||
}
|
||
|
||
# Редирект всех остальных запросов на HTTPS
|
||
location / {
|
||
return 301 https://$server_name$request_uri;
|
||
}
|
||
}
|
||
|
||
# HTTPS сервер
|
||
server {
|
||
listen 443 ssl http2;
|
||
server_name your-domain.com; # Замените на ваш домен
|
||
|
||
# SSL сертификаты Let's Encrypt
|
||
ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
|
||
ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;
|
||
|
||
# SSL настройки
|
||
ssl_protocols TLSv1.2 TLSv1.3;
|
||
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384;
|
||
ssl_prefer_server_ciphers off;
|
||
ssl_session_cache shared:SSL:10m;
|
||
ssl_session_timeout 10m;
|
||
|
||
# Максимальный размер загружаемых файлов
|
||
client_max_body_size 100M;
|
||
|
||
# Безопасность
|
||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
|
||
add_header X-Frame-Options DENY always;
|
||
add_header X-Content-Type-Options nosniff always;
|
||
add_header X-XSS-Protection "1; mode=block" always;
|
||
|
||
# Проксирование API запросов к backend
|
||
location /api/ {
|
||
proxy_pass http://127.0.0.1:3542;
|
||
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 300;
|
||
proxy_connect_timeout 300;
|
||
proxy_send_timeout 300;
|
||
}
|
||
|
||
# Проксирование всех остальных запросов к frontend
|
||
location / {
|
||
proxy_pass http://127.0.0.1:3001;
|
||
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 300;
|
||
proxy_connect_timeout 300;
|
||
proxy_send_timeout 300;
|
||
}
|
||
|
||
# Статические файлы Next.js с кэшированием
|
||
location /_next/static/ {
|
||
proxy_pass http://127.0.0.1:3001;
|
||
expires 1y;
|
||
add_header Cache-Control "public, immutable";
|
||
}
|
||
}
|
||
|
||
# Команды для настройки Let's Encrypt:
|
||
# 1. Установить certbot: sudo apt install certbot python3-certbot-nginx
|
||
# 2. Получить сертификат: sudo certbot --nginx -d your-domain.com
|
||
# 3. Проверить автообновление: sudo certbot renew --dry-run |