49 lines
1.4 KiB
Plaintext
49 lines
1.4 KiB
Plaintext
server {
|
|
listen 80;
|
|
server_name _;
|
|
|
|
root /config/www;
|
|
index index.html;
|
|
|
|
# CRITICAL: Include MIME types
|
|
include /etc/nginx/mime.types;
|
|
|
|
# Handle trailing slashes for directories
|
|
location ~ ^([^.]*[^/])$ {
|
|
try_files $uri $uri/ $uri.html =404;
|
|
}
|
|
|
|
# CORS configuration for search index
|
|
location /search/search_index.json {
|
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
|
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
|
|
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept' always;
|
|
|
|
if ($request_method = 'OPTIONS') {
|
|
return 204;
|
|
}
|
|
}
|
|
|
|
# Main location block
|
|
location / {
|
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
|
try_files $uri $uri/ $uri/index.html $uri.html /index.html =404;
|
|
}
|
|
|
|
# Handle 404 with MkDocs 404 page
|
|
error_page 404 /404.html;
|
|
location = /404.html {
|
|
internal;
|
|
}
|
|
|
|
# Static assets
|
|
location ~* \.(css|js|jpg|jpeg|png|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
|
expires 30d;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
# Enable gzip
|
|
gzip on;
|
|
gzip_types text/plain text/css text/javascript application/javascript application/json;
|
|
} |