56 lines
1.5 KiB
Nginx Configuration File
56 lines
1.5 KiB
Nginx Configuration File
|
|
server {
|
||
|
|
listen 80;
|
||
|
|
server_name _;
|
||
|
|
root /usr/share/nginx/html;
|
||
|
|
index index.html;
|
||
|
|
|
||
|
|
# Gzip compression
|
||
|
|
gzip on;
|
||
|
|
gzip_vary on;
|
||
|
|
gzip_proxied any;
|
||
|
|
gzip_comp_level 6;
|
||
|
|
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
|
||
|
|
|
||
|
|
# Security headers
|
||
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
||
|
|
add_header X-Content-Type-Options "nosniff" always;
|
||
|
|
add_header X-XSS-Protection "1; mode=block" always;
|
||
|
|
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||
|
|
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
|
||
|
|
|
||
|
|
# HTML — no cache (always fresh)
|
||
|
|
location ~* \.html$ {
|
||
|
|
add_header Cache-Control "no-store, no-cache, must-revalidate";
|
||
|
|
}
|
||
|
|
|
||
|
|
# Static assets — 1 year immutable
|
||
|
|
location ~* \.(css|js|webp|jpg|jpeg|png|gif|ico|svg|woff|woff2|ttf|eot|otf)$ {
|
||
|
|
expires 1y;
|
||
|
|
add_header Cache-Control "public, max-age=31536000, immutable";
|
||
|
|
access_log off;
|
||
|
|
}
|
||
|
|
|
||
|
|
# RSS/Atom feed MIME type
|
||
|
|
location ~* \.(rss|atom)$ {
|
||
|
|
types { application/rss+xml rss; application/atom+xml atom; }
|
||
|
|
}
|
||
|
|
|
||
|
|
# Clean URLs
|
||
|
|
location / {
|
||
|
|
try_files $uri $uri/ $uri.html =404;
|
||
|
|
}
|
||
|
|
|
||
|
|
# Custom 404
|
||
|
|
error_page 404 /404.html;
|
||
|
|
location = /404.html {
|
||
|
|
internal;
|
||
|
|
}
|
||
|
|
|
||
|
|
# Block hidden files
|
||
|
|
location ~ /\. {
|
||
|
|
deny all;
|
||
|
|
access_log off;
|
||
|
|
log_not_found off;
|
||
|
|
}
|
||
|
|
}
|