GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - g1ibby/ollama-auth: This project provides a Docker image for running the Ollama service with basic authentication using the Caddy server

BranchesTags
Open more actions menu

Latest commit

 

History

23 Commits
23 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.vscode
.vscode
 
 
.gitignore
.gitignore
 
 
Caddyfile
Caddyfile
 
 
Dockerfile
Dockerfile
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
docker-compose.yml
docker-compose.yml
 
 
start_services.sh
start_services.sh
 
 

Repository files navigation

Ollama with API Key Authentication

A secure Docker image that runs the Ollama service with API key authentication using Caddy as a reverse proxy. This setup provides multiple authentication methods while keeping your Ollama instance secure.

Quick Start

Using Docker

docker run -d \
  -p 11435:80 \
  -e OLLAMA_API_KEY=your-secret-api-key \
  -v ollama_data:/root/.ollama \
  ghcr.io/g1ibby/ollama-auth:latest

Using Docker Compose

curl -O https://raw.githubusercontent.com/g1ibby/ollama-auth/main/docker-compose.yml
# Edit docker-compose.yml to set your API key
docker-compose up -d

Authentication Methods

The service supports three authentication methods. Choose the one that best fits your client:

1. Bearer Token (Recommended)

curl -H "Authorization: Bearer your-secret-api-key" \
  http://localhost:11435/api/tags

2. Query Parameter

curl "http://localhost:11435/api/tags?api-key=your-secret-api-key"

3. Header-Based

curl -H "X-API-Key: your-secret-api-key" \
  http://localhost:11435/api/tags

Configuration

Environment Variables

Variable Required Description Default
OLLAMA_API_KEY ✅ API key for authentication -
OLLAMA_HOST ❌ Ollama bind address 0.0.0.0

Volume Mounts

  • /root/.ollama - Ollama models and configuration data

Using with Ollama Clients

OpenWebUI

Set the API base URL to http://localhost:11435 and configure authentication headers in your client.

Ollama CLI

export OLLAMA_HOST=http://localhost:11435
# Add API key to your requests

Python Client

import requests

headers = {"Authorization": "Bearer your-secret-api-key"}
response = requests.get("http://localhost:11435/api/tags", headers=headers)

Security Considerations

  • 🔑 Strong API Keys - Use long, randomly generated API keys
  • 🌐 Network Security - Consider using HTTPS in production with a reverse proxy
  • 🔄 Key Rotation - Regularly rotate your API keys
  • 📊 Monitoring - Monitor access logs for suspicious activity

Troubleshooting

Container won't start

  • Ensure OLLAMA_API_KEY environment variable is set
  • Check Docker logs: docker logs <container-name>

Authentication fails

  • Verify your API key matches the OLLAMA_API_KEY environment variable
  • Ensure you're using the correct authentication method
  • Check that the API key doesn't contain special characters that need escaping

Models not persisting

  • Ensure you're mounting a volume to /root/.ollama
  • Check volume permissions and available disk space

Contributing

Contributions are welcome!

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

This project provides a Docker image for running the Ollama service with basic authentication using the Caddy server

Topics

caddyllmollamaproxy

Resources

Readme
MIT license
Activity

Stars

19 stars

Watchers

2 watching

Forks

11 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.