security: add security headers to nginx config to prevent XSS, clickjacking and enforce HTTPS
This commit is contained in:
parent
218a774e1f
commit
e2aeca1de7
22
nginx.conf
22
nginx.conf
@ -5,6 +5,28 @@ server {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
|
||||
# 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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user