Browser Extension / LAN Client Gets HTTP 403 (CORS) or 502 Calling Local Ollama
Diagnose OLLAMA_ORIGINS rejections, Host header mismatches behind Nginx/Caddy, and mixed-content HTTPS->HTTP blocks.
Reproduce the failed request or simulate a browser Origin header with the curl command below.
curl -i -X OPTIONS http://127.0.0.1:11434/api/tags -H "Origin: chrome-extension://test" -H "Access-Control-Request-Method: POST"
If Ollama returns HTTP/1.1 403 Forbidden, its built-in Origin whitelist rejected the caller.
Read Full Reproducible Guide →All 1 Terminal Diagnostic Probes in "Browser Extension / LAN Client Gets HTTP 403 (CORS) or 502 Calling Local Ollama"
Complete static reference of every read-only probe command, baseline hint, and branch transition in this decision tree.
Reproduce the failed request or simulate a browser Origin header with the curl command below.
curl -i -X OPTIONS http://127.0.0.1:11434/api/tags -H "Origin: chrome-extension://test" -H "Access-Control-Request-Method: POST"
If Ollama returns HTTP/1.1 403 Forbidden, its built-in Origin whitelist rejected the caller.
- • Returns HTTP 403 Forbidden on OPTIONS or POST
→ sol-ollama-origins-env - • Returns 403/502 only when accessed through Nginx / Caddy reverse proxy
→ sol-proxy-host-header-rewrite - • Browser blocks request before sending (Mixed Content: HTTPS page -> HTTP LAN IP)
→ sol-mixed-content-https
3 Verified Root Causes, Fix Configs & Commands in "Browser Extension / LAN Client Gets HTTP 403 (CORS) or 502 Calling Local Ollama"
Fix: Configure OLLAMA_ORIGINS to Whitelist Browser Extensions & WebUIs
sol-ollama-origins-envOllama rejects browser requests carrying an Origin header other than localhost unless explicitly listed in OLLAMA_ORIGINS (to prevent malicious websites from querying your local models via CSRF).
- Set OLLAMA_ORIGINS="chrome-extension://*,moz-extension://*,http://192.168.*" (or "*" on a trusted loopback/proxy setup).
- Restart the Ollama service and verify the OPTIONS preflight returns 200/204.
# macOS (launchctl) launchctl setenv OLLAMA_ORIGINS "chrome-extension://*,moz-extension://*,http://localhost:*" # Linux systemd override (/etc/systemd/system/ollama.service.d/override.conf) [Service] Environment="OLLAMA_ORIGINS=chrome-extension://*,moz-extension://*,http://192.168.*"
[BOUNDARY]Avoid setting OLLAMA_ORIGINS="*" at the same time as OLLAMA_HOST="0.0.0.0" without an auth proxy, or any website you visit can invoke your local LLM.
curl -i -X OPTIONS http://127.0.0.1:11434/api/tags -H "Origin: chrome-extension://test" -H "Access-Control-Request-Method: POST"Fix: Rewrite Host Header to localhost:11434 in Reverse Proxy
sol-proxy-host-header-rewriteRecent Ollama versions validate the HTTP Host header against DNS rebinding attacks. If Nginx forwards Host: ai.homelab.local, Ollama returns 403.
- Keep Ollama bound strictly to 127.0.0.1:11434.
- Add `proxy_set_header Host localhost:11434;` in Nginx (or `header_up Host localhost:11434` in Caddy).
location / {
proxy_pass http://127.0.0.1:11434;
proxy_set_header Host localhost:11434;
proxy_buffering off;
proxy_read_timeout 300s;
}[BOUNDARY]Combine with Bearer token checks in Nginx so LAN users must authenticate.
curl -i http://127.0.0.1:11434/api/version -H "Host: localhost:11434"Fix: Terminate Local TLS via Caddy/Tailscale or Route via Server Backend
sol-mixed-content-httpsModern browsers strictly block HTTPS web apps from making fetch() calls to plain HTTP LAN addresses (e.g. http://192.168.1.50:11434), except http://127.0.0.1.
- If the client is a containerized web app (Open WebUI / LobeChat), configure the Ollama URL in its server-side backend environment rather than browser-direct mode.
- Or expose the LAN endpoint over HTTPS using Caddy internal TLS / Tailscale Serve.
# Caddyfile with automatic local TLS & Host rewrite
https://ollama.homelab.internal {
tls internal
reverse_proxy 127.0.0.1:11434 {
header_up Host localhost:11434
flush_interval -1
}
}[BOUNDARY]`http://127.0.0.1` is treated as a Secure Context by browsers, whereas `http://192.168.x.x` is not.
caddy validate --config CaddyfileFixing Local LLM HTTP 403 CORS, Reverse Proxy Host Headers & LAN Bearer Authentication
Why browser extensions and LAN web clients get HTTP 403 Forbidden from Ollama—and how to configure OLLAMA_ORIGINS, Host header rewrites, and Bearer token protection safely.
Nginx 1.26 / Caddy 2.8 · Ollama 0.5.7 · Chrome / Firefox Extensions & LAN Web Clients
Ollama 0.5.7 · Nginx 1.26+ · Caddy 2.8+
100% Intranet / LAN Authenticated Gateway — Keeps raw Ollama bound strictly to 127.0.0.1 while exposing a Bearer-authenticated port to trusted LAN devices.