Basic proxy to Ollama
Ollama exposes an OpenAI-compatible /v1/chat/completions endpoint. Proxy it with long timeouts — LLM responses are slow.
nginx
server {
listen 443 ssl;
server_name llm.example.com;
ssl_certificate /etc/letsencrypt/live/llm.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/llm.example.com/privkey.pem;
location /v1/ {
proxy_pass http://127.0.0.1:11434/v1/;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
client_max_body_size 10m;
}
}Rate limiting
Add a limit_req zone to prevent abuse on a public-facing VPS. Adjust rate for your expected users.
nginx
limit_req_zone $binary_remote_addr zone=llm:10m rate=10r/m;
location /v1/ {
limit_req zone=llm burst=5 nodelay;
proxy_pass http://127.0.0.1:11434/v1/;
proxy_read_timeout 300s;
}Related guides
BeginnerServer / VPS8 min read
Run Llama 3.1 8B on a €20/month VPS
A complete guide to running a private LLM API on a budget Linux VPS using llama.cpp server mode.
IntermediateServer / VPS12 min read
Multi-Model API Server on RTX 4090 with vLLM
Serve multiple AWQ-quantized models with vLLM's continuous batching for production-grade throughput.
IntermediateServer / VPS8 min read
TabbyAPI: ExLlamaV2 with a Web UI
Wrap ExLlamaV2 in TabbyAPI for a polished OpenAI-compatible server with streaming and model hot-swap.
Deployment guides are educational. Each model is subject to its own license — read the official Hugging Face model card before downloading or deploying.