mnemo_cards/tools/deploy/web-app/nginx.conf
2025-11-19 20:37:43 +03:00

69 lines
2.4 KiB
Nginx Configuration File

server {
listen 80;
server_name memo-cards.online;
# Redirect HTTP to HTTPS
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name memo-cards.online;
# SSL configuration - Let's Encrypt (preferred)
ssl_certificate /etc/letsencrypt/live/memo-cards.online/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/memo-cards.online/privkey.pem;
# Fallback to self-signed certificates if Let's Encrypt fails
# ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
# ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
# Client upload size limit (for large file uploads)
client_max_body_size 100M;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline' 'unsafe-eval'" always;
# Root directory
root /var/www/mnemo_cards;
index index.html;
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/javascript;
# Main location block
location / {
try_files $uri $uri/ /index.html;
# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}
# Handle Flutter web assets
location ~* \.(wasm|js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
# Removed COEP/COOP headers that interfere with CORS requests to API
# add_header Cross-Origin-Embedder-Policy "require-corp";
# add_header Cross-Origin-Opener-Policy "same-origin";
}
# Security - deny access to hidden files
location ~ /\. {
deny all;
}
}