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 API requests to backend container location /payroll/ { proxy_pass http://backend:18080/payroll/; 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; } location /payroll/employees/ { proxy_pass http://backend:18080/payroll/employees/; 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; } # Generic fallback to backend for other API paths location /api/ { 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; } }