server {
    listen 80;
    server_name localhost;
    
    root /usr/share/nginx/html;
    index index.html;

    # Enable gzip compression
    gzip on;
    gzip_vary on;
    gzip_min_length 1000;
    gzip_proxied any;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
    gzip_comp_level 6;

    # Cache static assets
    location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|webp|avif|otf|ttf|woff|woff2)$ {
        expires 30d;
        add_header Cache-Control "public, no-transform";
    }

    # Handle error pages
    error_page 404 /404.html;
    error_page 401 /401.html;
    
    location = /404.html {
        internal;
    }
    
    location = /401.html {
        internal;
    }

    # Handle all HTML files and directories
    location / {
        try_files $uri $uri/ /index.html;
    }
}
