44 lines
2.0 KiB
Nginx Configuration File
44 lines
2.0 KiB
Nginx Configuration File
# Use $request_id as a pseudo-nonce for Content Security Policy (CSP)
|
|
map $request_id $nonce {
|
|
default "$request_id";
|
|
}
|
|
|
|
server {
|
|
listen 8080;
|
|
root /usr/share/nginx/html;
|
|
index resume.html;
|
|
|
|
# Security headers
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
|
add_header Permissions-Policy "camera=(), microphone=(), geolocation=(), accelerometer=(), gyroscope=(), magnetometer=(), payment=(), usb=()" always;
|
|
|
|
# Content Security Policy (CSP) with injected $nonce for script-src
|
|
add_header Content-Security-Policy "default-src 'none'; script-src 'self' 'nonce-$nonce' https://matomo.nixc.us; style-src 'self' 'unsafe-inline' https://colinknapp.com; img-src 'self' https://matomo.nixc.us https://colinknapp.com https://hedgedoc.nixc.us; font-src 'self' data:; frame-ancestors 'self'; base-uri 'self'; form-action 'self';" always;
|
|
|
|
# Cross-origin isolation headers
|
|
add_header Cross-Origin-Embedder-Policy "require-corp" always;
|
|
add_header Cross-Origin-Resource-Policy "same-origin" always;
|
|
add_header Cross-Origin-Opener-Policy "same-origin" always;
|
|
|
|
# Subresource Integrity (SRI) requires modifying HTML for each script link to include integrity hashes
|
|
# Set up sub_filter to add nonce to inline scripts
|
|
sub_filter '<script>' '<script nonce="$nonce">';
|
|
sub_filter_once off;
|
|
sub_filter_types text/html;
|
|
|
|
# Redirect demo.hedgedoc.org resources to hedgedoc.nixc.us
|
|
sub_filter "https://demo.hedgedoc.org" "https://hedgedoc.nixc.us";
|
|
|
|
# Expect-CT Header
|
|
add_header Expect-CT "max-age=86400, enforce" always;
|
|
|
|
# Cache-Control for dynamic pages
|
|
location / {
|
|
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
|
|
try_files $uri $uri/ =404;
|
|
}
|
|
}
|