Skip to content

jampack/coolify-ollama-api-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ollama API Proxy

A secure proxy server for Ollama API with Bearer token authentication. Designed for Coolify deployment.

Features

  • 🔒 Bearer token authentication
  • 🔄 Full API proxying to Ollama
  • 🐳 Docker-ready for Coolify
  • 🏥 Health check endpoint
  • ⚡ Lightweight and fast

Configuration

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

Usage

Local Development

  1. Install dependencies:
npm install
  1. Create .env file:
cp .env.example .env
# Edit .env and set your BEARER_TOKEN
  1. Start the server:
npm start

Docker/Coolify Deployment

  1. Build the image:
docker build -t ollama-proxy .
  1. Run the container:
docker run -d \
  -p 3000:3000 \
  -e BEARER_TOKEN=your-secure-token \
  -e OLLAMA_URL=http://ollama:11434 \
  ollama-proxy

Coolify Setup

  1. Create a new application in Coolify
  2. Connect your repository
  3. Set environment variables:
    • BEARER_TOKEN - Your secure token
    • OLLAMA_URL - Your Ollama service URL (e.g., http://ollama:11434 if using service name)
  4. Deploy

API Usage

All requests must include the Bearer token in the Authorization header:

curl -H "Authorization: Bearer your-token" \
  http://localhost:3000/api/tags
curl -H "Authorization: Bearer your-token" \
  -H "Content-Type: application/json" \
  -d '{"model": "llama2", "prompt": "Hello"}' \
  http://localhost:3000/api/generate

Endpoints

  • GET /health - Health check (no auth required)
  • GET / - Service info (requires auth)
  • GET /api/* - All Ollama API endpoints (requires auth)

Security Notes

  • Always use a strong, randomly generated token in production
  • Keep your BEARER_TOKEN secret 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)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published