11# 🦙 Ollama API Server
2-
3- Secure your local Ollama instance with API keys and enhanced features - simple setup with Docker!
2+ A simple, easy-to-use api server that sits in front of your local ollama instance to add additional security when making requests to ollama.
43
54<a href =" https://www.buymeacoffee.com/gitmotion " target =" _blank " rel =" noopener noreferrer " >
65 <img src =" https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png " alt =" Buy me a coffee " width =" 150px " />
76</a >
87
98## 📑 Table of Contents
109- [ ⭐ Features] ( #⭐-features )
10+ - [ 🎛️ Example Flow] ( #🎛️-example-flow )
1111- [ 🚀 Quick Start] ( #🚀-quick-start )
1212- [ 📖 Detailed Setup] ( #📖-detailed-setup )
1313 - [ 🐳 Docker Setup (Recommended)] ( #🐳-docker-setup-recommended )
@@ -26,6 +26,48 @@ Secure your local Ollama instance with API keys and enhanced features - simple s
2626- 🐳 Easy Docker Setup
2727- 🔌 All Ollama API Endpoints Supported
2828
29+ ## 🎛️ Example Flow
30+ - Example of connecting a local ollama instance to an open-webui docker container on the same docker network
31+
32+ <div align =" center " >
33+ <img src =" https://github.com/user-attachments/assets/2840746e-9ea0-4f92-bcee-39115c5990ab " width =50% />
34+ </div >
35+
36+ ``` mermaid
37+ flowchart TD
38+ user([External User]) --> webui[Open WebUI]
39+
40+ webui -->|Request with API Key| api[Ollama API Server]
41+
42+ api --> auth{API Key Valid?}
43+ auth -->|No| reject[Reject Connection]
44+ auth -->|Yes| ollama[Ollama LLM Service]
45+
46+ ollama -->|Response| api
47+ api -->|Response| webui
48+ webui -->|Response| user
49+
50+ subgraph "Docker: ollama-network"
51+ webui
52+ api
53+ auth
54+ ollama
55+ end
56+
57+ classDef green fill:#d1e7dd,stroke:#0f5132,stroke-width:1px,color:#0f5132;
58+ classDef blue fill:#cfe2ff,stroke:#084298,stroke-width:1px,color:#084298;
59+ classDef red fill:#f8d7da,stroke:#842029,stroke-width:1px,color:#842029;
60+ classDef yellow fill:#fff3cd,stroke:#664d03,stroke-width:1px,color:#664d03;
61+ classDef gray fill:#f8f9fa,stroke:#343a40,stroke-width:1px,color:#343a40;
62+
63+ class user gray
64+ class webui blue
65+ class api blue
66+ class auth yellow
67+ class ollama green
68+ class reject red
69+ ```
70+
2971## 🚀 Quick Start
3072
3173``` bash
@@ -97,6 +139,47 @@ services:
97139 - API_KEYS=${API_KEYS:-default-key-1,default-key-2}
98140` ` `
99141
142+ #### Example of ollama-api-server with your open-webui stack:
143+ ` ` ` yaml
144+ services :
145+ ollama-api-server :
146+ image : gitmotion/ollama-api-server:latest
147+ container_name : ollama-api-server
148+ restart : unless-stopped
149+ ports :
150+ - " ${PORT_EXTERNAL:-7777}:7777"
151+ environment :
152+ - PORT=7777
153+ - OLLAMA_BASE_URL=http://internal-ip-where-ollama-installed:11434 # must serve your ollama server with 0.0.0.0
154+ - CORS_ORIGIN=*
155+ - API_KEYS=${API_KEYS:-secure-api-key-1,secure-api-key-2} # UPDATE THESE KEYS - comma separated
156+ networks :
157+ - ollama-network
158+
159+ open-webui :
160+ image : openwebui/open-webui:latest
161+ container_name : open-webui
162+ restart : unless-stopped
163+ depends_on :
164+ - ollama-api-server
165+ ports :
166+ - " 3000:3000"
167+ environment :
168+ - OLLAMA_BASE_URL=http://ollama-api-server:7777 # Configure the api key via UI
169+ - WEBUI_SECRET_KEY=${WEBUI_SECRET_KEY}
170+ volumes :
171+ - ./open-webui-data:/app/backend/data
172+ networks :
173+ - ollama-network
174+ - your-external-reverse-proxy
175+
176+ networks :
177+ ollama-network :
178+ driver : bridge
179+ your-external-reverse-proxy :
180+ external : true
181+ ` ` `
182+
100183This configuration:
101184- Uses the official Docker image
102185- Maps the container's port 7777 to your host's port (configurable via PORT_EXTERNAL)
0 commit comments