Blueprints · AI & LLMs
Production
25 min · Qdrant / PostgreSQL
Qdrant and pgvector isolation
Keeps Qdrant on localhost with an API key, terminates TLS at Nginx, and creates the pgvector extension on a localhost PostgreSQL. Snapshots are a cron script you run yourself.
Live config
Baked-in protections
- Qdrant is published on 127.0.0.1 only
- An API key is required
- TLS is the Nginx listener, not an open Qdrant port
- pgvector is created in one database
- The snapshot script is not run by the bundle
Step 1 · yaml
Qdrant compose
/opt/qdrant/compose.yaml
The API key is read from the environment file the writer creates.
services:
qdrant:
image: qdrant/qdrant:latest
environment:
QDRANT__SERVICE__API_KEY: ${QDRANT_API_KEY}
QDRANT__SERVICE__HOST: 0.0.0.0
ports:
- "127.0.0.1:6333:6333"
volumes:
- qdrant:/qdrant/storage
security_opt:
- no-new-privileges:true
restart: unless-stopped
volumes:
qdrant:
Step 2 · nginx
Nginx TLS and pgvector SQL
/etc/nginx/sites-available/vectors.example.com.conf
PostgreSQL must already listen on localhost. The SQL only creates the extension.
server {
listen 443 ssl;
server_name vectors.example.com;
ssl_certificate /etc/letsencrypt/live/vectors.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/vectors.example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
location / {
proxy_pass http://127.0.0.1:6333;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Step 3 · bash
API key file, SQL, and snapshot script
/root/portgate-blueprints/qdrant-write.sh
The snapshot script is written and not executed. Replace the API key before you start Qdrant.
#!/bin/sh set -eu install -d -m 755 "/opt/qdrant" umask 077 printf 'QDRANT_API_KEY=%s\n' "change-me" > "/opt/qdrant/.env" chmod 600 "/opt/qdrant/.env" cat > "/opt/qdrant/pgvector.sql" <<'EOF' CREATE EXTENSION IF NOT EXISTS vector; EOF cat > /root/portgate-blueprints/qdrant-snapshot.sh <<'EOF' #!/bin/sh set -eu curl -fsS -H "api-key: change-me" -X POST "http://127.0.0.1:6333/snapshots" sudo -u postgres psql -d "vectors" -c "CREATE EXTENSION IF NOT EXISTS vector;" EOF chmod 755 /root/portgate-blueprints/qdrant-snapshot.sh echo "Snapshot script written. It was not run."