lightweight go reverse proxy for ollama with bearer token authentication
go proxy ollama

refactor: use env prefix

Changed files
+12 -12
+2 -2
.env.example
···
# Ollama server URL (optional, defaults to http://localhost:11434)
OLLAMA_URL=http://localhost:11434
-
# Proxy server port (optional, defaults to 8080)
-
PORT=8080
+
# Proxy server port (optional, defaults to 11433)
+
PORT=11433
+6 -6
README.md
···
The proxy is configured via environment variables:
-
- `AUTH_TOKEN` (required): Bearer token for API authentication
-
- `OLLAMA_URL` (optional): Ollama server URL (default: `http://localhost:11434`)
-
- `PORT` (optional): Proxy server port (default: `8080`)
+
- `OP_AUTH_TOKEN` (required): Bearer token for API authentication
+
- `OP_OLLAMA_URL` (optional): Ollama server URL (default: `http://localhost:11434`)
+
- `OP_PORT` (optional): Proxy server port (default: `11433`)
## Usage
### Start the proxy
```bash
-
export AUTH_TOKEN="your-secret-token"
-
export OLLAMA_URL="http://localhost:11434"
-
export PORT="8080"
+
export OP_AUTH_TOKEN="your-secret-token"
+
export OP_OLLAMA_URL="http://localhost:11434"
+
export OP_PORT="11433"
ollama-proxy
```
+4 -4
main.go
···
)
const (
-
portEnv = "PORT"
-
authEnv = "AUTH_TOKEN"
-
ollamaEnv = "OLLAMA_URL"
+
portEnv = "OP_PORT"
+
authEnv = "OP_AUTH_TOKEN"
+
ollamaEnv = "OP_OLLAMA_URL"
)
func main() {
port := os.Getenv(portEnv)
if port == "" {
-
port = "8080"
+
port = "11433"
}
ollamaURL := os.Getenv(ollamaEnv)