
Speech-to-text looks effortless in a demo. In production, it can become a steady vendor bill. It can also raise awkward questions about where your audio ends up.
If you want everything on your own box, this walkthrough shows how to host Whisper API on a Linux VPS with Docker. You’ll put Nginx in front with Basic Auth and sensible rate limits.
By the end, you’ll have an HTTPS endpoint your apps can call (mobile, web, internal tools). You’ll also add guardrails so one noisy client can’t pin your CPU.
What you’re building (and what it’s good for)
You’ll run a Whisper-based transcription service in a container. Then you’ll publish it through Nginx:
- Private API endpoint at
https://stt.yourdomain.com/v1/transcribe(the exact path depends on the image; Nginx can normalize it). - Basic Auth so drive-by scans can’t hit your API.
- Rate limiting to rein in abusive clients and protect the VPS.
- Upload limits and timeouts sized for real audio files.
This is a CPU-first setup. GPU is faster.
CPU keeps costs predictable and ops simpler on a general-purpose VPS.
Server sizing for Whisper on CPU (honest expectations)
Transcription is expensive work. Size the server around your audio hours and the turnaround time you need.
- Minimum for light usage: 4 vCPU, 8 GB RAM, NVMe storage. Fine for short clips, a few users, and background jobs.
- Comfortable baseline: 8 vCPU, 16 GB RAM. Better for longer recordings and small bursts without constant queuing.
- Higher throughput: 16 vCPU, 32 GB RAM. Handles batch uploads and more concurrent requests (still CPU-bound).
Don’t ignore disk. Uploads, temp files, and logs grow quietly.
If you’ll keep originals, plan for at least 60–100 GB free.
If you’re starting fresh, a HostMyCode VPS is a straightforward way to run this on clean Ubuntu with predictable performance.
If you’d rather not handle OS patching and hardening yourself, managed VPS hosting is the better match.
Prerequisites (Ubuntu + a real DNS name)
You’ll need:
- Ubuntu Server on a VPS (22.04 LTS or 24.04 LTS both work well)
- A domain/subdomain pointed to your server (example:
stt.example.com) - Ports
80and443open to the internet
If DNS is still in progress, set it up with HostMyCode domains.
A wrong A/AAAA record is still the most common reason Let’s Encrypt fails.
Step 1: Install Docker and Docker Compose
On Ubuntu, the distro packages are a stable baseline. Install Docker and the Compose plugin, then enable the service.
sudo apt update
sudo apt install -y docker.io docker-compose-plugin apache2-utils
sudo systemctl enable --now docker
sudo usermod -aG docker $USER
Log out and back in so your user picks up the Docker group. Then confirm it’s working:
docker version
docker compose version
Step 2: Create a Docker Compose stack for the Whisper API
There are several Whisper server images, and they don’t all behave the same.
The main differences are routing, model handling, and resource controls.
The goal here is predictable ops: one container, one internal port, and a persistent data directory.
Create a project directory:
sudo mkdir -p /opt/whisper-api/data
sudo chown -R $USER:$USER /opt/whisper-api
cd /opt/whisper-api
Create docker-compose.yml:
cat > docker-compose.yml <<'YAML'
services:
whisper:
image: ghcr.io/some/whisper-api:latest
container_name: whisper-api
restart: unless-stopped
ports:
- "127.0.0.1:9000:9000"
environment:
- WHISPER_MODEL=small
- MAX_CONCURRENCY=2
- TMPDIR=/data/tmp
volumes:
- ./data:/data
YAML
Important: Replace ghcr.io/some/whisper-api:latest with the Whisper API image you trust and have vetted.
Keep your requirements simple. The container should listen on a single HTTP port and accept audio uploads.
If the image uses a different port, adjust the mapping.
Binding to 127.0.0.1 keeps the API off the public internet. Only Nginx can reach it.
Start the container:
docker compose up -d
docker compose logs -f --tail=100
In a second shell, confirm the port is listening locally:
curl -sS http://127.0.0.1:9000/ | head
If your image doesn’t serve /, try its health or docs endpoint. Common ones are /health or /docs.
If you still get nothing, check container logs. Also confirm it binds to 0.0.0.0:9000 inside the container.
Step 3: Install Nginx and get TLS certificates
Nginx will terminate HTTPS and proxy to the container on localhost. Install Nginx and Certbot:
sudo apt install -y nginx certbot python3-certbot-nginx
Create a DNS A/AAAA record for your subdomain (stt.example.com) pointing at the VPS. Then request a certificate:
sudo certbot --nginx -d stt.example.com
When Certbot asks, choose the HTTP-to-HTTPS redirect option.
Step 4: Add Basic Auth (simple but effective)
Basic Auth won’t replace a full auth system. It does block most random traffic.
It also prevents the common “oops, I found an open endpoint” failure.
Create a password file:
sudo htpasswd -c /etc/nginx/.htpasswd whisperuser
Use a long password and save it in your password manager. Your clients will need it.
Step 5: Configure Nginx reverse proxy + rate limits
Next, create an Nginx site file. This configuration includes:
- Basic Auth
- Per-IP request rate limiting
- Upload size limit for audio files
- Longer proxy timeouts so transcriptions don’t die mid-request
Create /etc/nginx/sites-available/whisper-api:
sudo tee /etc/nginx/sites-available/whisper-api > /dev/null <<'NGINX'
limit_req_zone $binary_remote_addr zone=whisper_ratelimit:10m rate=10r/m;
limit_conn_zone $binary_remote_addr zone=whisper_connlimit:10m;
server {
listen 80;
server_name stt.example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name stt.example.com;
ssl_certificate /etc/letsencrypt/live/stt.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/stt.example.com/privkey.pem;
client_max_body_size 50m;
auth_basic "Whisper API";
auth_basic_user_file /etc/nginx/.htpasswd;
limit_req zone=whisper_ratelimit burst=10 nodelay;
limit_conn whisper_connlimit 5;
location / {
proxy_pass http://127.0.0.1:9000;
proxy_http_version 1.1;
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_connect_timeout 10s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
}
}
NGINX
Enable the site and reload Nginx:
sudo rm -f /etc/nginx/sites-enabled/default
sudo ln -s /etc/nginx/sites-available/whisper-api /etc/nginx/sites-enabled/whisper-api
sudo nginx -t
sudo systemctl reload nginx
Why these limits? 10r/m is intentionally conservative. It supports a small app making periodic requests.
It also discourages brute-force attempts and “free transcription” scraping.
If you expect legitimate bursts (like retries from flaky mobile connections), increase burst first. Don’t raise the sustained rate until you’ve measured CPU impact.
If you need a different policy for trusted sources (office/VPN), use a second server block or a map with separate zones.
Keep it readable. You’ll want clarity when something goes wrong.
Step 6: Test transcription with curl
First, make sure auth is enforced:
curl -i https://stt.example.com/
You should see 401 Unauthorized. Now test with credentials.
The exact endpoint and form fields depend on the container you chose. You’ll usually see one of these patterns:
- Simple form upload at
/transcribeor/v1/transcribe - OpenAI-style endpoints (some servers mimic
/v1/audio/transcriptions)
Example for a generic /v1/transcribe that accepts file:
curl -u whisperuser:'YOUR_PASSWORD' \
-F file=@/path/to/sample.wav \
https://stt.example.com/v1/transcribe
If your server expects an OpenAI-style route, try:
curl -u whisperuser:'YOUR_PASSWORD' \
-F file=@/path/to/sample.wav \
-F model=whisper-1 \
https://stt.example.com/v1/audio/transcriptions
If you hit 413 Request Entity Too Large, increase client_max_body_size.
If you hit 504, increase proxy_read_timeout and check whether the CPU is maxed out.
Step 7: Tune concurrency so your VPS stays responsive
Most Whisper servers expose a worker or concurrency setting. It’s tempting to crank it up.
On CPU, that usually backfires. Throughput drops and latency becomes erratic.
Start here:
- 4 vCPU: concurrency 1–2
- 8 vCPU: concurrency 2–4
- 16 vCPU: concurrency 4–8
Then test with real workloads. Watch CPU steal (noisy neighbors), load average, and RAM pressure:
sudo apt install -y htop
htop
If you run your website on the same VPS, leave headroom. Transcription can starve PHP-FPM, Node, or your database quickly.
For mixed workloads, moving speech-to-text to its own instance is usually the cleanest fix. It’s also a good reason to add a second HostMyCode VPS.
Step 8: Add basic abuse protection beyond Nginx
Nginx limits help, but they won’t stop repeated password guessing forever. Two practical upgrades:
- Firewall: allow only 22/80/443 (plus any monitoring ports you actually use).
- Intrusion protection: auto-ban repeat offenders.
For a clean ban pipeline, follow our guide on installing CrowdSec on Ubuntu VPS and add an Nginx bouncer. It’s easier to maintain than hand-rolled log parsing.
If this endpoint is only for internal use, consider putting it behind a private overlay instead of publishing it publicly.
For a “not on the public internet” admin interface, see Cloudflare Tunnel for private admin access.
Step 9: Logging and disk hygiene (so the VPS doesn’t fill up)
Two places tend to grow without warning:
- Nginx logs:
/var/log/nginx/access.logand/var/log/nginx/error.log - Container data/tmp: whatever your image writes to
/data
For the first few weeks, check space regularly until you know your baseline:
df -h
sudo du -sh /opt/whisper-api/data/* 2>/dev/null
sudo du -sh /var/log/nginx/* 2>/dev/null
If you suddenly run out of disk, don’t guess. Walk through it methodically: Disk full on VPS: find large files safely.
Step 10: Make it usable for real apps (example integrations)
Once the endpoint behaves, treat it like any other internal dependency:
- Keep uploads under a predictable max duration (split long recordings client-side).
- Queue jobs instead of making users wait on a single long request.
- Cache results using a hash of the audio file to avoid re-transcribing duplicates.
For most web apps, the pattern is simple:
- Upload audio to object storage (or your own disk).
- Enqueue a job.
- Call the API from a worker.
- Write the transcript to your database.
You avoid browser timeouts. You also control concurrency centrally.
Common failure modes (and quick fixes)
- Clients get 401 even with correct password: confirm the username and password file path, then reload Nginx. Check for special characters that need shell escaping.
- 413 errors for normal audio files: raise
client_max_body_sizeand ensure the upstream server also allows the size. - 504 Gateway Timeout on longer files: increase
proxy_read_timeoutand reduce concurrency. Timeouts are often a symptom of CPU saturation. - API is slow after a few hours: check memory pressure and swap. Also inspect container logs for repeated model reloads.
- Everything is “up” but requests hang: verify the upstream port binding (
127.0.0.1:9000) and confirm the container is healthy.
Summary: a production-safe way to host speech-to-text
You now have a Whisper transcription API on your own infrastructure. It’s protected by TLS, Basic Auth, and rate limits.
The design stays intentionally boring: a localhost-only upstream, one Nginx site, and a few clear knobs for uploads, timeouts, and concurrency.
If you need higher throughput or lower latency, the next step is GPU inference or splitting workloads across servers.
If your goal is predictable billing and direct control, starting with a HostMyCode VPS and scaling up is usually smoother than rebuilding later on shared resources.
Planning to host Whisper API for a private speech-to-text endpoint? Put it on infrastructure you control. A HostMyCode VPS works well as a dedicated transcription node, and managed VPS hosting is a better fit if you want patching, monitoring, and ongoing server hygiene handled for you.
FAQ
Can I run Whisper API on the same VPS as my website?
You can, but transcriptions can overload the box fast. For WordPress or a production app, a separate VPS for speech-to-text keeps web latency stable.
Is Basic Auth enough to secure a Whisper endpoint?
It’s a solid baseline with HTTPS and rate limits. For higher-risk deployments, add IP allowlists, a VPN/tunnel, or an API gateway that issues per-client tokens.
What audio formats should I accept?
WAV and MP3 are the most predictable. If users upload anything, convert server-side with ffmpeg before sending to the Whisper API to reduce failures and normalize sample rates.
How do I handle long recordings reliably?
Split audio into chunks (for example, 30–120 seconds), transcribe each chunk, then stitch the text. This reduces timeouts and makes retries cheaper.
What’s the fastest way to improve performance without a GPU?
Use a smaller model, keep concurrency low to avoid CPU thrash, and keep files local (NVMe). The biggest wins usually come from queueing jobs and controlling request bursts.