Ollama + Nginx Reverse Proxy Setup Guide
π Prerequisites
Before you begin, ensure you have:
- A server (e.g., Ubuntu) with root access
- Nginx installed
- Certbot (for SSL certificates via Letβs Encrypt)
- Ollama installed and running TinyLlama locally
βοΈ Step 1: Install and Run Ollama + TinyLlama
# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh
# Start Ollama service
sudo systemctl enable ollama
sudo systemctl start ollama
# Pull the TinyLlama model
ollama pull tinyllama
# Run it locally (default listens on port 11434)
ollama run tinyllama
π Step 2: Configure Nginx Reverse Proxy
Create or edit the Nginx config file:
sudo nano /etc/nginx/sites-available/app.wakeupcoders.com
Paste this configuration:
server {
server_name app.wakeupcoders.com www.app.wakeupcoders.com;
location / {
proxy_pass http://127.0.0.1:11434;
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Origin ββ;
proxy_set_header Referer ββ;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/app.wakeupcoders.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/app.wakeupcoders.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = app.wakeupcoders.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name app.wakeupcoders.com www.app.wakeupcoders.com;
return 404; # managed by Certbot
}
Save and exit (CTRL+O, ENTER, CTRL+X).
Then enable and test:
sudo ln -s /etc/nginx/sites-available/app.wakeupcoders.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
π Step 3: Set Up SSL with Certbot
If you havenβt already:
sudo apt install certbot python3-certbot-nginx -y
sudo certbot β nginx -d app.wakeupcoders.com -d www.app.wakeupcoders.com
π Step 4: Test the Setup
Visit: https://app.wakeupcoders.com
To test with curl:
curl -X POST https://app.wakeupcoders.com/api/generate \
-d '{"model":"tinyllama","prompt":"Hello, world!"}' \
-H "Content-Type: application/json"Expected response (example):
{"response": "Hello! How can I help you today?"}