ARTIFACT // NGINX-OLLAMA-LAN-AUTH.CONF (SHELL)
Secure LAN Reverse Proxy for Ollama / vLLM (Bearer Auth + CORS + Unbuffered SSE) (nginx-ollama-lan-auth.conf)
Protects local port 11434 behind an Nginx reverse proxy with API key authentication, clean CORS headers for browser extensions, and 300s SSE streaming.
[KEY VERIFIED TAKEAWAY / TL;DR]This reproducible configuration artifact "Secure LAN Reverse Proxy for Ollama / vLLM (Bearer Auth + CORS + Unbuffered SSE)" (nginx-ollama-lan-auth.conf, SHELL) is paired with Tinker AI Lab's hardware-verified guide "cors-reverse-proxy-auth-local-llm". It exposes 3 customizable browser variables (PROXY_LISTEN_PORT=11435, LAN_BEARER_TOKEN=sk-tinker-homelab-secret-2026, ALLOWED_ORIGIN=*) with loopback-first security defaults.
04 // DIAGNOSISAPI & Deployment Troubleshooting· Verified: 2026-10-23
Browse All 42 Artifacts →nginx-ollama-lan-auth.conf
View Paired Guide →Secure LAN Reverse Proxy for Ollama / vLLM (Bearer Auth + CORS + Unbuffered SSE)
Protects local port 11434 behind an Nginx reverse proxy with API key authentication, clean CORS headers for browser extensions, and 300s SSE streaming.
Customizable Variables (Saved in Browser)
UTF-8 Encoded · Live Client-Side Compilation
# Tinker AI — Secure Nginx Reverse Proxy for Local Ollama (Keep Ollama on 127.0.0.1:11434)
map $http_authorization $auth_ok {
default 0;
"Bearer sk-tinker-homelab-secret-2026" 1;
}
server {
listen 0.0.0.0:11435;
server_name _;
location / {
# Handle browser / Chrome extension CORS preflight
if ($request_method = OPTIONS) {
add_header Access-Control-Allow-Origin "*" always;
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always;
add_header Access-Control-Allow-Headers "Authorization, Content-Type" always;
return 204;
}
if ($auth_ok = 0) {
return 401 '{"error":"Unauthorized: valid Bearer token required"}';
}
proxy_pass http://127.0.0.1:11434;
proxy_set_header Host localhost:11434;
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 300s;
chunked_transfer_encoding on;
}
}
PARAMETER SPECIFICATION // 参数化变量规范说明表
Customizable Parameter Reference for nginx-ollama-lan-auth.conf
This SHELL artifact exposes 3 template variables compiled client-side in your browser.
| Template Token | Parameter Description | Verified Default | Example Format |
|---|---|---|---|
{{PROXY_LISTEN_PORT}} | LAN Proxy Port | 11435 | 11435 |
{{LAN_BEARER_TOKEN}} | Required Bearer Token Secret | sk-tinker-homelab-secret-2026 | sk-tinker-homelab-secret-2026 |
{{ALLOWED_ORIGIN}} | Allowed Browser CORS Origin | * | * |
PAIRED HARDWARE MANIFEST // 配套实测环境与边界记录
Verified Environment for "Fixing Local LLM HTTP 403 CORS, Reverse Proxy Host Headers & LAN Bearer Authentication"
Tested Hardware & OS
Nginx 1.26 / Caddy 2.8 · Ollama 0.5.7 · Chrome / Firefox Extensions & LAN Web Clients
Pinned Stack & Model Versions
Ollama 0.5.7Nginx 1.26+Caddy 2.8+
Offline Boundary (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.
Known Operational Limits & Failure Modes
- Security Hazard: Setting `OLLAMA_HOST=0.0.0.0` AND `OLLAMA_ORIGINS=*` simultaneously without a reverse proxy allows ANY public website you visit in your browser to silently query or delete your local models.
- Modern browsers block HTTPS web apps (e.g. `https://app.example.com`) from calling plain HTTP LAN IPs (`http://192.168.1.50:11434`) due to Mixed Content / Private Network Access policy.
DEPLOYMENT CHECKLIST // 配置落地核验步骤
3-Step Verification Checklist After Deploying nginx-ollama-lan-auth.conf
- Scoped `OLLAMA_ORIGINS` to `chrome-extension://*,moz-extension://*` instead of wildcard `*` on exposed hosts.
- Configured `proxy_set_header Host localhost:11434;` and `proxy_buffering off;` in the reverse proxy.
- Protected LAN-facing model endpoints with a Bearer token so unauthorized clients receive HTTP 401.