server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # Serve static files location / { # Try to serve the exact file, then directory, otherwise fall back to index.html # This ensures accessing / or any SPA route returns /index.html try_files $uri $uri/ /index.html; } # Proxy all API requests to backend location ~ ^/(accounts|journals|ledger|trial-balance|opening-balances|general-ledger|payroll|users|month-locks|year-locks|cash|file-upload|egov) { proxy_pass http://backend:18080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }