87 lines
2.6 KiB
Plaintext
87 lines
2.6 KiB
Plaintext
upstream bcards_backend {
|
|
server 141.148.162.114:8080;
|
|
server 129.146.116.218:8080;
|
|
|
|
# Health check settings
|
|
keepalive 32;
|
|
}
|
|
|
|
server {
|
|
listen 80;
|
|
server_name bcards.site www.bcards.site;
|
|
|
|
# Redirect HTTP to HTTPS
|
|
return 301 https://$server_name$request_uri;
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl http2;
|
|
server_name bcards.site www.bcards.site;
|
|
|
|
# SSL Configuration
|
|
ssl_certificate /etc/letsencrypt/live/bcards.site/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/bcards.site/privkey.pem;
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384;
|
|
ssl_prefer_server_ciphers off;
|
|
ssl_session_cache shared:SSL:10m;
|
|
ssl_session_timeout 10m;
|
|
|
|
# Security headers
|
|
add_header X-Frame-Options DENY;
|
|
add_header X-Content-Type-Options nosniff;
|
|
add_header X-XSS-Protection "1; mode=block";
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
|
|
# Gzip compression
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_min_length 1024;
|
|
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;
|
|
|
|
# Load balancer configuration
|
|
location / {
|
|
proxy_pass http://bcards_backend;
|
|
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;
|
|
|
|
# Connection settings
|
|
proxy_connect_timeout 30s;
|
|
proxy_send_timeout 30s;
|
|
proxy_read_timeout 30s;
|
|
|
|
# Buffer settings
|
|
proxy_buffering on;
|
|
proxy_buffer_size 4k;
|
|
proxy_buffers 8 4k;
|
|
|
|
# Health check
|
|
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
|
|
proxy_next_upstream_tries 2;
|
|
proxy_next_upstream_timeout 30s;
|
|
}
|
|
|
|
# Health check endpoint
|
|
location /health {
|
|
access_log off;
|
|
proxy_pass http://bcards_backend;
|
|
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;
|
|
}
|
|
|
|
# Static files (if any)
|
|
location /static {
|
|
proxy_pass http://bcards_backend;
|
|
proxy_cache_valid 200 1h;
|
|
expires 1h;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
# Logging
|
|
access_log /var/log/nginx/bcards_access.log;
|
|
error_log /var/log/nginx/bcards_error.log;
|
|
} |