server { listen 80; server_name app.maia.depaoli.id.au; # Set the root directory for static files root /usr/share/nginx/html; # Default file to serve index index.html index.htm; location / { # Crucial for SPAs: # - Try to serve the requested file ($uri) # - If it's not found, try it as a directory ($uri/) # - If that's not found, serve index.html (letting client-side routing handle it) try_files $uri $uri/ /index.html; } # Add gzip compression for better performance gzip on; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss text/javascript image/svg+xml; # Improve caching for assets location ~* \.(?:css|js|jpg|jpeg|gif|png|ico|svg|woff|woff2|ttf|eot)$ { expires 1y; add_header Cache-Control "public"; access_log off; # Don't log access for static assets } # Deny access to hidden files location ~ /\. { deny all; } }