A simple proxy server for Ollama that adds authentication to requests.
This proxy server forwards all requests to an Ollama API endpoint while adding an Authorization: Bearer token header for authentication. It supports all Ollama API endpoints and preserves original request methods, paths, headers, and bodies.
The proxy can be configured with environment variables or, equivalently, with command-line flags. Each option supports both syntaxes — when a flag and its environment variable are both set, the flag wins.
| Env variable | Flag (serve) |
Default | Description |
|---|---|---|---|
HOST |
--host |
127.0.0.1 |
Interface to bind to (--listen-all = 0.0.0.0) |
PORT |
--port |
22434 |
Port to run the proxy server on |
API_ENDPOINT |
--api-endpoint |
http://localhost:11434 |
Target API endpoint to forward requests to |
API_KEY |
--api-key |
(empty) | API key used for authentication |
DISABLE_AUTO_UPDATE |
— | false |
Disable auto-update |
UPDATE_CHECK_INTERVAL |
— | 24h |
How often to check for updates |
Deprecated:
OLLAMA_ENDPOINT/--ollama-endpointstill work as aliases forAPI_ENDPOINT/--api-endpoint, but print a warning. Prefer the new names; the aliases may be removed in a future release.
Configuration can be provided in multiple ways:
- Command-line flags:
goophy serve --port 22434 --api-endpoint http://localhost:11434 --api-key sk-...(the--flag=valueform works too, e.g.--port=22434) - Environment variables:
PORT=22434 API_ENDPOINT=http://localhost:11434 goophy serve - From a
.envfile in the current directory (automatically loaded) - From a custom env file specified with the
--env-fileflag:goophy --env-file my-config.env serve
Flags and --env-file may be placed before or after the command — goophy serve --env-file my-config.env
and goophy --env-file my-config.env serve are equivalent.
See example.env for a sample configuration file format.
https://github.com/NorskHelsenett/goophy/releases
Create a .env file with the following content:
API_ENDPOINT="https://openwebui.com/ollama"
API_KEY="sk-your-key-from-OWUI"Then run the following container:
docker run --rm --env-file .env -p 22434:22434 ghcr.io/norskhelsenett/goophy serve# Build the application
go build -o goophy cmd/goophy/main.go
# Or with custom version
go build -ldflags="-X main.version=0.1.3" -o goophy ./cmd/goophy/
# Run the proxy with default settings
./goophy serve
# Run with custom settings using flags
./goophy serve --port 22434 --api-endpoint https://my-api-server.example.com/v1 --api-key my-secret-key
# ...or the equivalent environment variables
PORT=22434 API_ENDPOINT=https://my-api-server.example.com/v1 API_KEY=my-secret-key ./goophy serve
# Run with settings from a config file (flag works before or after the command)
./goophy --env-file my-config.env serve
./goophy serve --env-file my-config.env
# A .env file in the current directory is automatically loaded
# echo "API_KEY=my-secret-key" > .env
# ./goophy serveYou can also build and run this proxy in Docker:
# Build the Docker image
docker build -t ollama-proxy .
# Run the container
docker run -p 22434:22434 -e API_ENDPOINT=https://my-api-server.example.com/v1 -e API_KEY=my-secret-key ollama-proxyOpenWebUI is accessible at the /ollama endpoint, so using it would be like example.com/ollama.
This application is built for multiple platforms:
- macOS (Intel/AMD64 and Apple Silicon/ARM64)
- Linux (AMD64 and ARM64)
- Windows (AMD64 and ARM64)
You can download the latest release from the releases page.
To run this on MacOSX due to Gatekeeper, you have to add this binary to the allowlist by running
xattr -d com.apple.quarantine ~/.local/bin/goophy
echo 'export OLLAMA_HOST="http://localhost:22434"' >> .zshrcBy exporting the OLLAMA_HOST environment its possible to use ollama ps|run|pull|rm... without specifying this environment for every request.
The application includes an automatic update feature that:
- Checks for new versions on GitHub when the application starts
- Performs periodic checks every 24 hours
- Automatically downloads and applies updates in the background
The auto-update system will handle the different archive formats for each platform:
.tar.gzfor macOS and Linux.zipfor Windows
To disable auto-updates, set the environment variable:
DISABLE_AUTO_UPDATE=true ./goophyYou can also customize the update check interval:
UPDATE_CHECK_INTERVAL=12h ./goophyThis proxy supports all Ollama API endpoints by forwarding requests to the target Ollama server. Check the Ollama documentation for a complete list of API endpoints.
Common endpoints include:
/api/generate- Generate text from a prompt/api/chat- Chat with a model/api/embeddings- Get embeddings for a text/api/models- List available models (OpenAI-compatible)
# Call the proxy to chat with a model
curl -X POST http://localhost:22434/api/chat -d '{
"model": "llama3.2",
"messages": [{"role": "user", "content": "Hello, how are you?"}]
}'The proxy will forward this request to your Ollama endpoint with the added authentication header and return the response.
