mnemo_cards/tools/deploy/web-app/nginx.conf

70 lines
2.4 KiB
Nginx Configuration File
Raw Permalink Normal View History

2025-11-10 23:55:41 +00:00
server {
listen 80;
2025-11-19 22:40:56 +00:00
server_name mnemo-cards.online;
2025-11-16 12:15:21 +00:00
2025-11-10 23:55:41 +00:00
# Redirect HTTP to HTTPS
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
2025-11-19 22:40:56 +00:00
server_name mnemo-cards.online;
2025-11-16 12:15:21 +00:00
# SSL configuration - Let's Encrypt (preferred)
2025-11-19 22:40:56 +00:00
ssl_certificate /etc/letsencrypt/live/mnemo-cards.online/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mnemo-cards.online/privkey.pem;
2025-11-16 12:15:21 +00:00
# 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;
2025-11-10 23:55:41 +00:00
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;
2025-11-19 17:37:43 +00:00
# Client upload size limit (for large file uploads)
2025-11-21 09:31:34 +00:00
client_max_body_size 1000M;
2025-11-19 17:37:43 +00:00
2025-11-10 23:55:41 +00:00
# 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";
2025-11-16 12:15:21 +00:00
# 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";
2025-11-10 23:55:41 +00:00
}
# Security - deny access to hidden files
location ~ /\. {
deny all;
}
}