90 lines
2.9 KiB
Plaintext
90 lines
2.9 KiB
Plaintext
# Example Nginx Reverse Proxy Configuration
|
|
# This is an OPTIONAL configuration if you want to use Nginx as your reverse proxy
|
|
# The application runs on HTTP and does not require nginx - you can use any reverse proxy
|
|
|
|
# Step 1: Install nginx and certbot
|
|
# sudo apt install nginx certbot python3-certbot-nginx
|
|
|
|
# Step 2: Create this file at /etc/nginx/sites-available/faction-war
|
|
# Replace 'yourdomain.com' with your actual domain
|
|
# Replace '8000' with your application port if different
|
|
|
|
# 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 (will be managed by Certbot)
|
|
# After running certbot, these lines will be automatically added:
|
|
# ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
|
|
# ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
|
|
# 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 / {
|
|
# Replace 8000 with your application port if different
|
|
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";
|
|
}
|
|
}
|
|
|
|
# Step 3: Enable the site
|
|
# sudo ln -s /etc/nginx/sites-available/faction-war /etc/nginx/sites-enabled/
|
|
|
|
# Step 4: Test configuration
|
|
# sudo nginx -t
|
|
|
|
# Step 5: Get SSL certificate with Certbot
|
|
# sudo certbot --nginx -d yourdomain.com
|
|
|
|
# Step 6: Reload nginx
|
|
# sudo systemctl reload nginx
|
|
|
|
# Step 7: Configure firewall
|
|
# sudo ufw allow 80/tcp
|
|
# sudo ufw allow 443/tcp
|
|
|
|
# Your application will now be accessible at https://yourdomain.com
|