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

refactor: use env prefix

+12 -12
+2 -2
.env.example
··· 5 5 # Ollama server URL (optional, defaults to http://localhost:11434) 6 6 OLLAMA_URL=http://localhost:11434 7 7 8 - # Proxy server port (optional, defaults to 8080) 9 - PORT=8080 8 + # Proxy server port (optional, defaults to 11433) 9 + PORT=11433
+6 -6
README.md
··· 24 24 25 25 The proxy is configured via environment variables: 26 26 27 - - `AUTH_TOKEN` (required): Bearer token for API authentication 28 - - `OLLAMA_URL` (optional): Ollama server URL (default: `http://localhost:11434`) 29 - - `PORT` (optional): Proxy server port (default: `8080`) 27 + - `OP_AUTH_TOKEN` (required): Bearer token for API authentication 28 + - `OP_OLLAMA_URL` (optional): Ollama server URL (default: `http://localhost:11434`) 29 + - `OP_PORT` (optional): Proxy server port (default: `11433`) 30 30 31 31 ## Usage 32 32 33 33 ### Start the proxy 34 34 35 35 ```bash 36 - export AUTH_TOKEN="your-secret-token" 37 - export OLLAMA_URL="http://localhost:11434" 38 - export PORT="8080" 36 + export OP_AUTH_TOKEN="your-secret-token" 37 + export OP_OLLAMA_URL="http://localhost:11434" 38 + export OP_PORT="11433" 39 39 ollama-proxy 40 40 ```
+4 -4
main.go
··· 10 10 ) 11 11 12 12 const ( 13 - portEnv = "PORT" 14 - authEnv = "AUTH_TOKEN" 15 - ollamaEnv = "OLLAMA_URL" 13 + portEnv = "OP_PORT" 14 + authEnv = "OP_AUTH_TOKEN" 15 + ollamaEnv = "OP_OLLAMA_URL" 16 16 ) 17 17 18 18 func main() { 19 19 port := os.Getenv(portEnv) 20 20 if port == "" { 21 - port = "8080" 21 + port = "11433" 22 22 } 23 23 24 24 ollamaURL := os.Getenv(ollamaEnv)