uri.defaults
🧩 Syntax:
# $KYAULabs: uri.defaults,v 1.0.3 2021/05/16 12:46:22 kyau Exp $
# remove `robots.txt` and all favicons from the logs
location ~* "^/(favicon\.\S{3,5}|robots\.txt)$" {
access_log off;
allow all;
log_not_found off;
}
# disable dot (hidden) files while allowing `.well-known`
location ~* /\.(?!well-known).* {
access_log off;
deny all;
log_not_found off;
}
# deny access to any sensitive material
location ~* (?:#.*#|\.(?:bak|conf|dist|fla|in[ci]|log|orig|phps|psd|sass|scss|sh|sql|sw[op])|~)$ {
access_log on;
deny all;
log_not_found on;
}
# asset/media cache
location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
access_log off;
expires 7d;
}
# fonts/svg cache and access
location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
access_log off;
add_header Access-Control-Allow-Origin "*";
expires 7d;
}
# html processing
location ~* \.html$ {
try_files $uri $uri/ /index.html =404;
}
# http error pages
error_page 404 /404;
error_page 500 502 503 504 /50x;
location = /404 {
root /nginx/https/error;
index 404.php;
}
location = /50x {
root /nginx/https/error;
index 50x.php;
}
# vim: ft=nginx sts=4 sw=4 ts=4 noet :