← back to Kamatera Nginx
sites-available/bubbe.ai
96 lines
# HTTP - Redirect to HTTPS
server {
listen 80;
listen [::]:80;
server_name bubbe.ai www.bubbe.ai;
# Let's Encrypt verification
location ^~ /.well-known/acme-challenge/ {
root /var/www/html;
default_type "text/plain";
try_files $uri =404;
}
# Redirect all HTTP to HTTPS
location / {
return 301 https://$server_name$request_uri;
}
}
# HTTPS - Redirect non-www to www
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name bubbe.ai;
# SSL Configuration
ssl_certificate /etc/letsencrypt/live/bubbe.ai/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/bubbe.ai/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# Redirect to www
return 301 https://www.bubbe.ai$request_uri;
}
# HTTPS - Main site (www)
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.bubbe.ai;
# SSL Configuration
ssl_certificate /etc/letsencrypt/live/bubbe.ai/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/bubbe.ai/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# Cloudflare Real IP Restoration
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 188.114.96.0/20;
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 104.16.0.0/13;
set_real_ip_from 104.24.0.0/14;
set_real_ip_from 172.64.0.0/13;
set_real_ip_from 131.0.72.0/22;
real_ip_header CF-Connecting-IP;
# 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;
# Proxy API requests to backend
location /api/ {
proxy_pass http://[::1]:3011/api/;
proxy_http_version 1.1;
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;
}
# Proxy to Bubbe chat app
location / {
proxy_pass http://[::1]:3011;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
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;
proxy_cache_bypass $http_upgrade;
}
}