server { listen 80; root /usr/share/nginx/html; # Default file to serve for directory requests index index.html index.htm; location / { # Try to serve the requested file directly ($uri) # If it's a directory, try serving the index file ($uri/) # If neither exists, fall back to serving /index.html try_files $uri $uri/ /index.html; } # Optional: Add cache control headers for static assets for better performance location ~* \.(?:css|js|jpg|jpeg|gif|png|ico|svg|webp)$ { expires 1y; add_header Cache-Control "public"; access_log off; # Optional: Don't log accesses for static files } }