You’ve been asked to stand up a Qdrant cluster so the RAG pipeline can finally move off the laptop notebook. The container runs, the SDK connects, the team indexes 50,000 documents and retrieval works. Six months later, the embeddings are stale because nobody rebuilt the index after the embedding model was upgraded, the REST API is on 0.0.0.0:6333 with no API key because the quickstart never asked for one, an external scraper has been pulling the whole collection through the unauthenticated /collections/{name}/points/scroll endpoint for weeks, and the only snapshot on disk is from the day the service started.
What’s happening
A Qdrant deployment that actually backs a production RAG needs more than docker run qdrant/qdrant. The REST listener on :6333 and the gRPC listener on :6334 must require an API key — Qdrant ships with auth off, and every collection endpoint, including scroll and search, is wide open by default. Both listeners belong behind nginx with Let’s Encrypt; the host should publish :443 only. The snapshot endpoint has to write to a real persistent directory mounted from /var/lib/qdrant/snapshots so you can ship snapshots to object storage on a schedule, because rebuilding an HNSW index from source documents through a paid embedding API is slow and expensive — typical small RAGs run 5-10k vectors per GB RAM in HNSW, and a 50k-vector rebuild from OpenAI text-embedding-3-small is a real bill. Telemetry must be off (Qdrant phones home by default). And the data directory needs to live on a volume the VM-level backup actually covers.
How to verify
After install, the host should only expose :443 and :22:
ss -lntp | grep -E ':(80|443|6333|6334)\b'
# 0.0.0.0:443 nginx
# 127.0.0.1:6333 qdrant (via compose)
# 127.0.0.1:6334 qdrant (via compose)
The REST endpoint must reject an unauthenticated call and accept one with the API key:
curl -sS -o /dev/null -w '%{http_code}\n' https://qdrant.example.com/collections
# 401
curl -sS -H "api-key: $QDRANT_API_KEY" https://qdrant.example.com/collections | jq .status
# "ok"
The snapshot directory should be writable and the cluster healthy:
curl -sS -H "api-key: $QDRANT_API_KEY" https://qdrant.example.com/healthz
# healthz check passed
ls -ld /var/lib/qdrant/snapshots
# drwx------ 2 root root ... /var/lib/qdrant/snapshots
If the unauthenticated call returns 200 or the snapshot directory does not exist, the production posture is gone — assume the index has been read by someone you did not invite.
The fix
Save the script below as /root/setup-qdrant-ubuntu22.sh, then run it. It installs Qdrant on a fresh Ubuntu 22.04 VM via Docker Compose: base update, UFW (SSH + HTTP + HTTPS only), SSH hardening with root key preserved, unattended-upgrades, Docker CE + compose plugin, a Qdrant container with REST and gRPC bound to 127.0.0.1 only, persistent storage and snapshot directories under /var/lib/qdrant, API-key auth enabled via production.yaml, telemetry disabled, nginx terminating TLS for the REST listener with a long-body limit for snapshot uploads, Let’s Encrypt via the certbot nginx plugin, and a poll loop that waits for :6333 and :443 before declaring success.
#!/usr/bin/env bash
set -euo pipefail
### Ubuntu 22.04 Qdrant clean VM installer
### Keeps root SSH key login enabled
### Disables SSH password login
### Enables automatic security updates
### Installs and configures Docker + Qdrant + nginx + Let's Encrypt
### API-key auth enforced on REST and gRPC
### No local backups; assumes VM-level backup
### Vector indexes can be rebuilt from source docs, but reproducibility is
### slower than restoring a Qdrant snapshot — ship snapshots to object storage.
### Reboot remains manual
if [[ "$(id -u)" -ne 0 ]]; then
echo "Run as root."
exit 1
fi
: "${QDRANT_DOMAIN:?Set QDRANT_DOMAIN=qdrant.example.com}"
: "${QDRANT_EMAIL:?Set QDRANT_EMAIL=ops@example.com for Let's Encrypt}"
QDRANT_VERSION="${QDRANT_VERSION:-v1.12.4}"
QDRANT_API_KEY="${QDRANT_API_KEY:-$(openssl rand -hex 32)}"
QDRANT_READ_API_KEY="${QDRANT_READ_API_KEY:-$(openssl rand -hex 32)}"
echo
echo "========================================"
echo "Qdrant Ubuntu 22.04 Setup"
echo "========================================"
echo
echo "==> Updating base OS"
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get -y upgrade
echo "==> Installing base packages"
apt-get -y install \
vim curl wget ca-certificates gnupg2 \
chrony fail2ban unattended-upgrades \
ufw lsof tcpdump dnsutils tar gzip \
iproute2 net-tools openssl jq \
software-properties-common
echo "==> Enabling time sync"
systemctl enable --now chrony
timedatectl set-ntp true
echo "==> Applying kernel/network tuning"
cat > /etc/sysctl.d/99-qdrant.conf <<'SYSCTL'
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
net.core.somaxconn = 4096
net.core.netdev_max_backlog = 250000
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_fin_timeout = 15
net.ipv4.ip_local_port_range = 10240 65535
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
kernel.dmesg_restrict = 1
kernel.kptr_restrict = 2
fs.file-max = 2097152
vm.max_map_count = 262144
SYSCTL
modprobe tcp_bbr || true
echo tcp_bbr > /etc/modules-load.d/bbr.conf
sysctl --system
echo "==> Setting file limits"
cat > /etc/security/limits.d/99-qdrant.conf <<'LIMITS'
* soft nofile 64000
* hard nofile 64000
root soft nofile 64000
root hard nofile 64000
LIMITS
echo "==> Configuring UFW"
ufw --force reset
ufw default deny incoming
ufw default allow outgoing
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw --force enable
echo "==> Hardening SSH while keeping root SSH key login enabled"
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak.$(date +%F-%H%M%S)
set_sshd_option() {
local key="$1"
local value="$2"
if grep -qE "^[#[:space:]]*${key}[[:space:]]+" /etc/ssh/sshd_config; then
sed -i "s|^[#[:space:]]*${key}[[:space:]].*|${key} ${value}|" /etc/ssh/sshd_config
else
echo "${key} ${value}" >> /etc/ssh/sshd_config
fi
}
set_sshd_option PermitRootLogin prohibit-password
set_sshd_option PasswordAuthentication no
set_sshd_option PubkeyAuthentication yes
set_sshd_option KbdInteractiveAuthentication no
set_sshd_option ChallengeResponseAuthentication no
set_sshd_option X11Forwarding no
set_sshd_option ClientAliveInterval 300
set_sshd_option ClientAliveCountMax 2
set_sshd_option MaxAuthTries 4
sshd -t
systemctl restart ssh
echo "==> Configuring fail2ban"
mkdir -p /etc/fail2ban/jail.d
cat > /etc/fail2ban/jail.d/sshd.local <<'FAIL2BAN'
[sshd]
enabled = true
port = ssh
backend = systemd
maxretry = 4
findtime = 10m
bantime = 1h
FAIL2BAN
systemctl enable --now fail2ban
echo "==> Configuring unattended-upgrades for security"
cat > /etc/apt/apt.conf.d/20auto-upgrades <<'AUTOUPG'
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
APT::Periodic::AutocleanInterval "7";
AUTOUPG
echo "==> Installing Docker CE"
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
| gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu jammy stable" \
> /etc/apt/sources.list.d/docker.list
apt-get update
apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
systemctl enable --now docker
echo "==> Preparing Qdrant data and snapshot directories"
mkdir -p /var/lib/qdrant/storage /var/lib/qdrant/snapshots /opt/qdrant
chmod 700 /var/lib/qdrant /var/lib/qdrant/storage /var/lib/qdrant/snapshots
echo "==> Writing Qdrant production config"
cat > /opt/qdrant/production.yaml <<QDRANT
log_level: INFO
service:
host: 0.0.0.0
http_port: 6333
grpc_port: 6334
enable_cors: false
api_key: ${QDRANT_API_KEY}
read_only_api_key: ${QDRANT_READ_API_KEY}
max_request_size_mb: 64
storage:
storage_path: /qdrant/storage
snapshots_path: /qdrant/snapshots
on_disk_payload: true
performance:
max_search_threads: 0
max_optimization_threads: 1
telemetry_disabled: true
cluster:
enabled: false
QDRANT
chmod 600 /opt/qdrant/production.yaml
echo "==> Writing env file"
cat > /opt/qdrant/.env <<ENV
QDRANT_VERSION=${QDRANT_VERSION}
QDRANT_API_KEY=${QDRANT_API_KEY}
QDRANT_READ_API_KEY=${QDRANT_READ_API_KEY}
ENV
chmod 600 /opt/qdrant/.env
echo "==> Writing docker-compose.yml"
cat > /opt/qdrant/docker-compose.yml <<'COMPOSE'
services:
qdrant:
image: qdrant/qdrant:${QDRANT_VERSION}
restart: unless-stopped
ports:
- "127.0.0.1:6333:6333"
- "127.0.0.1:6334:6334"
volumes:
- /var/lib/qdrant/storage:/qdrant/storage
- /var/lib/qdrant/snapshots:/qdrant/snapshots
- /opt/qdrant/production.yaml:/qdrant/config/production.yaml:ro
environment:
QDRANT__SERVICE__API_KEY: ${QDRANT_API_KEY}
QDRANT__SERVICE__READ_ONLY_API_KEY: ${QDRANT_READ_API_KEY}
QDRANT__TELEMETRY_DISABLED: "true"
ulimits:
nofile:
soft: 64000
hard: 64000
healthcheck:
test: ["CMD-SHELL", "bash -c ':> /dev/tcp/127.0.0.1/6333' || exit 1"]
interval: 30s
timeout: 5s
retries: 5
start_period: 30s
COMPOSE
echo "==> Starting Qdrant"
docker compose --env-file /opt/qdrant/.env -f /opt/qdrant/docker-compose.yml up -d
echo "==> Waiting for Qdrant REST on 127.0.0.1:6333"
for i in {1..60}; do
if ss -lntp | grep -q '127.0.0.1:6333'; then
break
fi
sleep 2
done
if ! ss -lntp | grep -q '127.0.0.1:6333'; then
echo "Qdrant failed to listen on 127.0.0.1:6333"
docker compose -f /opt/qdrant/docker-compose.yml logs --tail=200 qdrant || true
exit 1
fi
echo "==> Verifying API-key enforcement"
HTTP_CODE_NOAUTH="$(curl -sS -o /dev/null -w '%{http_code}' http://127.0.0.1:6333/collections || true)"
if [[ "$HTTP_CODE_NOAUTH" != "401" && "$HTTP_CODE_NOAUTH" != "403" ]]; then
echo "WARNING: Qdrant REST returned ${HTTP_CODE_NOAUTH} without api-key. Expected 401/403."
fi
echo "==> Installing nginx and certbot"
apt-get -y install nginx certbot python3-certbot-nginx
cat > /etc/nginx/sites-available/qdrant <<NGINX
upstream qdrant_backend {
server 127.0.0.1:6333;
keepalive 32;
}
server {
listen 80;
listen [::]:80;
server_name ${QDRANT_DOMAIN};
return 301 https://\$host\$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name ${QDRANT_DOMAIN};
client_max_body_size 256M;
proxy_read_timeout 600s;
proxy_send_timeout 600s;
proxy_connect_timeout 60s;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Content-Type-Options nosniff always;
add_header X-Frame-Options DENY always;
add_header Referrer-Policy strict-origin-when-cross-origin always;
location / {
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_http_version 1.1;
proxy_pass http://qdrant_backend;
}
}
NGINX
ln -sf /etc/nginx/sites-available/qdrant /etc/nginx/sites-enabled/qdrant
rm -f /etc/nginx/sites-enabled/default
nginx -t
systemctl enable --now nginx
systemctl reload nginx
echo "==> Requesting Let's Encrypt certificate"
certbot --nginx --non-interactive --agree-tos \
-m "${QDRANT_EMAIL}" -d "${QDRANT_DOMAIN}" --redirect
systemctl enable --now certbot.timer
echo "==> Waiting for HTTPS listener"
for i in {1..30}; do
if ss -lntp | grep -q ':443'; then
break
fi
sleep 1
done
echo "==> Final package update"
apt-get -y upgrade
echo
echo "========================================"
echo "DONE"
echo "========================================"
echo
echo "Kernel:"
uname -r
echo
echo "SSH effective settings:"
sshd -T | grep -E '^(permitrootlogin|passwordauthentication|pubkeyauthentication) ' || true
echo
echo "Listeners:"
ss -lntp | grep -E ':(80|443|6333|6334)\b' || true
echo
echo "Containers:"
docker compose -f /opt/qdrant/docker-compose.yml ps
echo
echo "Services:"
systemctl is-active docker nginx fail2ban chrony || true
echo
echo "Snapshot directory:"
ls -ld /var/lib/qdrant/snapshots
echo
echo "Healthz over HTTPS (with api-key):"
curl -sS -H "api-key: ${QDRANT_API_KEY}" "https://${QDRANT_DOMAIN}/healthz" || true
echo
echo "Secrets written to /opt/qdrant/.env (mode 600). Move them to your secrets manager and remove the file from this host before going live."
echo
echo "Admin API key (full read/write):"
echo "${QDRANT_API_KEY}"
echo
echo "Read-only API key (for retrieval-only clients):"
echo "${QDRANT_READ_API_KEY}"
echo
echo "REST endpoint:"
echo "https://${QDRANT_DOMAIN}"
echo
echo "First steps:"
echo "1. Create your first collection: curl -X PUT -H \"api-key: <key>\" https://${QDRANT_DOMAIN}/collections/docs -d '{\"vectors\":{\"size\":1536,\"distance\":\"Cosine\"}}'"
echo "2. Schedule snapshots: curl -X POST -H \"api-key: <key>\" https://${QDRANT_DOMAIN}/collections/docs/snapshots"
echo "3. Ship /var/lib/qdrant/snapshots to object storage on a cron."
Make it executable and run it:
chmod 700 /root/setup-qdrant-ubuntu22.sh
QDRANT_DOMAIN=qdrant.example.com QDRANT_EMAIL=ops@example.com /root/setup-qdrant-ubuntu22.sh
The script prints the admin API key and the read-only key at the end — wire those into your retrieval clients and embedding ingest jobs immediately, then move them out of /opt/qdrant/.env into your secrets manager. Schedule a daily POST to /collections/<name>/snapshots and a sync from /var/lib/qdrant/snapshots to object storage; if you ever lose the volume, restoring from a snapshot is the difference between a 5-minute recovery and re-embedding the whole corpus.
Run the production Qdrant on a Stack Harbor-managed environment with monitoring on the API endpoint, snapshot freshness alerts, and Sev-1 escalation: Managed Cloud Ops.