server { listen 80; root /usr/share/nginx/html; index index.html; # SPA fallback — let React Router handle unknown paths location / { try_files $uri $uri/ /index.html; } # Proxy Ollama's API through the same origin so the browser never has to # make a cross-origin request and CORS is a non-issue. # In the app's Settings panel, set the Ollama base URL to just: # http:// (no port, no path suffix) location /api/ { proxy_pass http://ollama:11434/api/; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # Ollama responses (especially streamed ones) can be large and slow; # disable buffering so cancellation works promptly. proxy_buffering off; proxy_read_timeout 300s; } }