93 lines
2.8 KiB
Plaintext
93 lines
2.8 KiB
Plaintext
# SmartSolTech Nginx Configuration
|
||
# Скопировать в: /etc/nginx/sites-available/smartsoltech
|
||
|
||
# Редирект с www на non-www
|
||
server {
|
||
listen 80;
|
||
listen [::]:80;
|
||
server_name www.smartsoltech.kr;
|
||
return 301 https://smartsoltech.kr$request_uri;
|
||
}
|
||
|
||
# HTTP → HTTPS редирект
|
||
server {
|
||
listen 80;
|
||
listen [::]:80;
|
||
server_name smartsoltech.kr;
|
||
|
||
# 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 smartsoltech.kr;
|
||
|
||
# SSL сертификаты (раскомментировать после получения от Let's Encrypt)
|
||
# ssl_certificate /etc/letsencrypt/live/smartsoltech.kr/fullchain.pem;
|
||
# ssl_certificate_key /etc/letsencrypt/live/smartsoltech.kr/privkey.pem;
|
||
# ssl_trusted_certificate /etc/letsencrypt/live/smartsoltech.kr/chain.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 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 X-XSS-Protection "1; mode=block" always;
|
||
|
||
# Максимальный размер загружаемых файлов
|
||
client_max_body_size 100M;
|
||
|
||
# Логи
|
||
access_log /var/log/nginx/smartsoltech_access.log;
|
||
error_log /var/log/nginx/smartsoltech_error.log;
|
||
|
||
# Статические файлы - ВАЖНО: должны быть ПЕРЕД location /
|
||
location /static/ {
|
||
alias /opt/smartsoltech_site/smartsoltech/staticfiles/;
|
||
expires 30d;
|
||
add_header Cache-Control "public, immutable";
|
||
access_log off;
|
||
}
|
||
|
||
# Медиа файлы
|
||
location /media/ {
|
||
alias /opt/smartsoltech_site/smartsoltech/media/;
|
||
expires 7d;
|
||
add_header Cache-Control "public";
|
||
access_log off;
|
||
}
|
||
|
||
# Прокси к Django приложению
|
||
location / {
|
||
proxy_pass http://localhost:8000;
|
||
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;
|
||
proxy_set_header X-Forwarded-Port $server_port;
|
||
proxy_redirect off;
|
||
proxy_buffering off;
|
||
|
||
# Таймауты
|
||
proxy_connect_timeout 60s;
|
||
proxy_send_timeout 60s;
|
||
proxy_read_timeout 60s;
|
||
}
|
||
}
|