Set up Reverse Proxy for Ollama
These steps walk you through connecting SidebarAI Chat to your own models and services.
1. Configure Ollama with a Reverse Proxy
Run Ollama behind a secure reverse proxy so it can be reached from your browser. Map the proxy to the port where Ollama listens and enable HTTPS.
Ollama enforces a strict CORS policy and rejects unknown origins. Requests from the Chrome extension include a chrome-extension://
origin that Ollama blocks, so the proxy must handle CORS headers.
If you need to install Nginx, see Set up Nginx on Windows, Linux, and macOS.
Create new file
(detecting OS...)
server {
listen 8080;
server_name localhost;
client_max_body_size 100M;
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' 'chrome-extension://ID';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
# CORS headers for actual requests
add_header 'Access-Control-Allow-Origin' 'chrome-extension://ID' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always;
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
# Proxy to Ollama
proxy_pass http://127.0.0.1:11434;
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;
# Remove/override Origin header to prevent leakage
proxy_set_header Origin "";
# Handle streaming responses
proxy_buffering off;
proxy_cache off;
# Increase timeouts for long-running requests
proxy_connect_timeout 60s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
}
}
2. Provide API Keys
Create or obtain API keys from your chosen model providers. In the extension's settings, add each key under the appropriate provider.
3. Verify Connectivity
Open the sidebar and start a test chat. If the model responds, your setup is complete.