MyFavStuff5/nginx.conf

43 lines
1.6 KiB
Nginx Configuration File

server {
listen 80;
server_name _; # Listen for any server name
root /usr/share/nginx/html;
index index.html index.htm;
# Debug header to verify our nginx config is loaded
add_header X-Custom-Config "MyFavStuff5-Nginx-Active" always;
# Security Headers
# Content Security Policy (CSP) - Prevents XSS attacks
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self'; connect-src 'self'; frame-ancestors 'none';" always;
# Strict Transport Security (HSTS) - Forces HTTPS
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
# X-Frame-Options - Prevents clickjacking
add_header X-Frame-Options "DENY" always;
# X-Content-Type-Options - Prevents MIME type sniffing
add_header X-Content-Type-Options "nosniff" always;
# Referrer Policy - Controls referrer information
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
# X-XSS-Protection - Additional XSS protection (legacy but still useful)
add_header X-XSS-Protection "1; mode=block" always;
# Permissions Policy - Controls browser features
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
location / {
try_files $uri $uri/ /index.html;
}
# Optional: You can add custom error pages if you create them in your 'static' folder
# error_page 404 /404.html;
# location = /404.html {
# internal;
# }
}