59 lines
1.8 KiB
Plaintext
59 lines
1.8 KiB
Plaintext
# HTTP - Redirect to HTTPS
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name yourdomain.com; # REPLACE WITH YOUR DOMAIN
|
|
|
|
# Redirect all HTTP to HTTPS
|
|
return 301 https://$server_name$request_uri;
|
|
}
|
|
|
|
# HTTPS - Main Application
|
|
server {
|
|
listen 443 ssl http2;
|
|
listen [::]:443 ssl http2;
|
|
server_name yourdomain.com; # REPLACE WITH YOUR DOMAIN
|
|
|
|
# SSL Configuration (managed by Certbot)
|
|
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem; # REPLACE
|
|
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem; # REPLACE
|
|
include /etc/letsencrypt/options-ssl-nginx.conf;
|
|
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
|
|
|
# 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;
|
|
|
|
# Logging
|
|
access_log /var/log/nginx/faction-war-access.log;
|
|
error_log /var/log/nginx/faction-war-error.log;
|
|
|
|
# Proxy settings
|
|
location / {
|
|
proxy_pass http://127.0.0.1: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;
|
|
|
|
# WebSocket support (if needed in future)
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
# Timeouts
|
|
proxy_connect_timeout 60s;
|
|
proxy_send_timeout 60s;
|
|
proxy_read_timeout 60s;
|
|
}
|
|
|
|
# Static files (optional optimization)
|
|
location /static/ {
|
|
alias /opt/faction-war/app/static/;
|
|
expires 1d;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
}
|