A secure proxy server for Ollama API with Bearer token authentication. Designed for Coolify deployment.
- 🔒 Bearer token authentication
- 🔄 Full API proxying to Ollama
- 🐳 Docker-ready for Coolify
- 🏥 Health check endpoint
- ⚡ Lightweight and fast
Set the following environment variables:
PORT- Port for the proxy server (default: 3000)OLLAMA_URL- Ollama service URL (default: http://localhost:11434)BEARER_TOKEN- Required bearer token for authentication
- Install dependencies:
npm install- Create
.envfile:
cp .env.example .env
# Edit .env and set your BEARER_TOKEN- Start the server:
npm start- Build the image:
docker build -t ollama-proxy .- Run the container:
docker run -d \
-p 3000:3000 \
-e BEARER_TOKEN=your-secure-token \
-e OLLAMA_URL=http://ollama:11434 \
ollama-proxy- Create a new application in Coolify
- Connect your repository
- Set environment variables:
BEARER_TOKEN- Your secure tokenOLLAMA_URL- Your Ollama service URL (e.g.,http://ollama:11434if using service name)
- Deploy
All requests must include the Bearer token in the Authorization header:
curl -H "Authorization: Bearer your-token" \
http://localhost:3000/api/tagscurl -H "Authorization: Bearer your-token" \
-H "Content-Type: application/json" \
-d '{"model": "llama2", "prompt": "Hello"}' \
http://localhost:3000/api/generateGET /health- Health check (no auth required)GET /- Service info (requires auth)GET /api/*- All Ollama API endpoints (requires auth)
- Always use a strong, randomly generated token in production
- Keep your
BEARER_TOKENsecret and never commit it to version control - The proxy removes the authorization header before forwarding to Ollama
- Consider using HTTPS in production (configure in Coolify)