# Redirect ALL HTTP to HTTPS (non-www)server{listen80;server_namedomain.comwww.domain.com;return301https://domain.com$request_uri;}# Redirect HTTPS www to HTTPS non-wwwserver{listen443ssl;server_namewww.domain.com;ssl_certificate/etc/letsencrypt/live/domain.com/fullchain.pem;ssl_certificate_key/etc/letsencrypt/live/domain.com/privkey.pem;return301https://domain.com$request_uri;}# Main server block for domain.com (HTTPS, non-www)server{listen443ssl;server_namedomain.com;ssl_certificate/etc/letsencrypt/live/domain.com/fullchain.pem;ssl_certificate_key/etc/letsencrypt/live/domain.com/privkey.pem;# SSL Security Settingsssl_protocolsTLSv1.2TLSv1.3;ssl_prefer_server_cipherson;# Security Headersadd_headerX-Robots-Tag"index,follow"always;add_headerStrict-Transport-Security"max-age=15768000;includeSubDomains;preload"always;add_headerContent-Language"en";add_headerReferrer-Policy"no-referrer-when-downgrade"always;add_headerX-Frame-Options"SAMEORIGIN"always;add_headerX-Content-Type-Options"nosniff"always;add_headerX-XSS-Protection"1;mode=block"always;# Real IP settingsreal_ip_headerX-Forwarded-For;real_ip_recursiveon;# Global tuningclient_max_body_size0;underscores_in_headerson;# Loggingaccess_log/var/log/nginx/domain.access.loggeoip2;error_log/var/log/nginx/domain.error.log;# Main proxy to containerlocation/{proxy_passhttp://192.168.0.xxx/;proxy_http_version1.1;proxy_set_headerHost$host;proxy_set_headerX-Real-IP$remote_addr;proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;proxy_set_headerX-Forwarded-Proto$scheme;proxy_set_headerUpgrade$http_upgrade;proxy_set_headerConnection"Upgrade";}# ACME Challenge for Let's Encryptlocation^~/.well-known/acme-challenge/{allowall;root/var/www/html;}# Security.txt handlerlocation^~/.well-known/security.txt{root/var/www/html;}}