41 lines
1.2 KiB
Nginx Configuration File
41 lines
1.2 KiB
Nginx Configuration File
server {
|
|
listen 80;
|
|
server_name _;
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# Enable gzip compression
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_min_length 1024;
|
|
gzip_proxied any;
|
|
gzip_types text/plain text/css text/xml text/javascript application/javascript application/json application/xml+rss;
|
|
|
|
# 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;
|
|
|
|
# Handle Next.js static export routes
|
|
location / {
|
|
# Try exact file, then .html extension, then directory index, then fallback
|
|
# Note: $uri.html must come before $uri/ to handle directories without index.html
|
|
try_files $uri $uri.html $uri/index.html /index.html;
|
|
}
|
|
|
|
# Cache static assets
|
|
location /_next/static/ {
|
|
add_header Cache-Control "public, max-age=31536000, immutable";
|
|
}
|
|
|
|
# Cache other static files
|
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, max-age=31536000";
|
|
}
|
|
|
|
# Custom error pages
|
|
error_page 404 /404.html;
|
|
error_page 500 502 503 504 /500.html;
|
|
}
|