This project provides an HTTPS proxy for Ollama, allowing secure communication with the Ollama API server.
- Docker and Docker Compose
- Ollama running on the host machine (default port: 11434)
-
Clone this repository:
git clone https://github.com/your-username/easy-proxy-ollama-https.git cd easy-proxy-ollama-https
-
Start the Docker container:
docker-compose up --build -d
-
The proxy will be available at
https://localhost:11435
To avoid browser warnings about the self-signed certificate, you need to add the root CA certificate to your system's trust store. Follow the steps for your operating system:
- Open Terminal and navigate to the project directory.
- Run the following command:
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ssl/rootCA.pem
- Enter your administrator password when prompted.
- Open Terminal and navigate to the project directory.
- Run the following commands:
sudo cp ssl/rootCA.pem /usr/local/share/ca-certificates/ollama-proxy-rootCA.crt sudo update-ca-certificates
- Open PowerShell as Administrator and navigate to the project directory.
- Run the following command:
Import-Certificate -FilePath ".\ssl\rootCA.pem" -CertStoreLocation Cert:\LocalMachine\Root
Firefox uses its own certificate store, so you need to import the certificate separately:
- Open Firefox settings.
- Search for "certificates" and click "View Certificates".
- In the "Authorities" tab, click "Import".
- Select the
ssl/rootCA.pem
file and trust it for identifying websites.
After starting the Docker container and trusting the certificate, you can make HTTPS requests to the proxy. For example:
curl https://localhost:11435/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "qwen2:0.5b",
"messages": [
{
"role": "user",
"content": "Hello, how are you?"
}
]
}'
Replace qwen2:0.5b
with the model you're using in Ollama.
The self-signed certificate is for development and testing purposes only. For production use, obtain a properly signed certificate from a trusted Certificate Authority.