On vous demande de monter AnythingLLM pour que l’équipe exploitation puisse interroger les runbooks, l’équipe contrats puisse fouiller la bibliothèque de politiques, et les RH puissent chercher dans le guide de l’employé — chaque équipe dans son propre espace de travail, chacune avec son propre fournisseur LLM. Le démarrage rapide Docker fonctionne, les premiers PDF sont téléversés, la récupération a l’air bonne. Six mois plus tard, l’unique mot de passe administrateur partagé traîne dans trois fils Slack, le secret JWT est la valeur par défaut amont parce que personne n’a défini la variable d’environnement, les incorporations que l’équipe contrats a téléversées dorment dans le même index vectoriel que le guide RH parce que les espaces de travail n’ont jamais été imposés comme frontières d’isolation, et la base SQLite a été montée dans un répertoire hôte que la sauvegarde au niveau de la VM ignore.
Ce qui se passe
Un déploiement AnythingLLM qui remplace réellement un prototype « chatter avec des PDF » partagé demande beaucoup plus que docker run mintplexlabs/anythingllm. La couche de persistance doit être PostgreSQL, pas SQLite — les espaces de travail multi-utilisateurs avec historique de fil par conversation et permissions par document génèrent des écritures concurrentes que SQLite traite en sérialisant chaque requête derrière un verrou global. PostgreSQL doit rester sur le réseau compose interne — jamais publié. Le magasin de vecteurs doit être soit Qdrant (quand vous en exploitez déjà un), soit LanceDB sur un volume persistant ; dans les deux cas, les données doivent vivre quelque part que la sauvegarde au niveau de la VM couvre. Le conteneur web s’assoit derrière nginx avec Let’s Encrypt ; l’hôte ne doit publier que :443. Le mode multi-utilisateur doit être activé dès le premier démarrage pour que les espaces de travail deviennent de vraies frontières d’isolation de données — le mode mono-utilisateur par défaut laisse n’importe qui avec l’URL voir tous les documents. Le JWT_SECRET et le sel du hachage de mot de passe d’authentification doivent être définis explicitement et persistés ; les roulouter invalide chaque session existante et chaque lien de réinitialisation de mot de passe en vol.
Comment vérifier
Après installation, l’hôte ne doit exposer que :443 et :22 :
ss -lntp | grep -E ':(80|443|3001|5432|6333)\b'
# 0.0.0.0:443 nginx
# 127.0.0.1:3001 anythingllm (via compose)
PostgreSQL sur 5432 et Qdrant sur 6333 ne doivent pas apparaître côté hôte. L’endpoint d’authentification doit exiger des identifiants :
curl -sS -o /dev/null -w '%{http_code}\n' https://chat.example.com/api/system/check-token
# 401 (sans Authorization)
L’endpoint d’information système en HTTPS ne doit retourner du JSON qu’avec une clé API d’espace de travail :
curl -sS -H "Authorization: Bearer $WORKSPACE_API_KEY" \
https://chat.example.com/api/v1/system | jq .Authentication
Si l’endpoint d’authentification retourne 200 sans entête bearer, le mode multi-utilisateur est désactivé et chaque espace de travail est ouvert — activez-le avant qu’un autre document soit téléversé.
Le correctif
Enregistrez le script ci-dessous sous /root/setup-anythingllm-ubuntu22.sh, puis exécutez-le. Il installe AnythingLLM sur une VM Ubuntu 22.04 fraîche via Docker Compose : mise à jour de base, UFW (SSH + HTTP + HTTPS uniquement), durcissement SSH avec conservation de l’accès clé root, unattended-upgrades, Docker CE + plugin compose, PostgreSQL maintenu sur le réseau interne, un sidecar Qdrant optionnel sur le réseau interne (réglez VECTOR_DB=qdrant ; sinon LanceDB est utilisé sur un volume persistant), le conteneur AnythingLLM avec mode multi-utilisateur forcé via AUTH_TOKEN et JWT_SECRET écrits dans /opt/anythingllm/.env en chmod 600, nginx qui termine TLS avec une limite de corps généreuse pour les téléversements de documents, Let’s Encrypt via le plugin nginx de certbot, et une boucle d’attente qui valide :3001 puis :443 avant de déclarer succès.
#!/usr/bin/env bash
set -euo pipefail
### Ubuntu 22.04 AnythingLLM clean VM installer
### Keeps root SSH key login enabled
### Disables SSH password login
### Enables automatic security updates
### Installs and configures Docker + AnythingLLM + PostgreSQL (+ optional Qdrant) + nginx + Let's Encrypt
### Multi-user mode forced; JWT_SECRET persisted; vector store on a persistent volume
### No local backups; assumes VM-level backup
### Vector indexes can be rebuilt from source docs, but reproducibility is slow.
### Reboot remains manual
if [[ "$(id -u)" -ne 0 ]]; then
echo "Run as root."
exit 1
fi
: "${ANYTHINGLLM_DOMAIN:?Set ANYTHINGLLM_DOMAIN=chat.example.com}"
: "${ANYTHINGLLM_EMAIL:?Set ANYTHINGLLM_EMAIL=ops@example.com for Let's Encrypt}"
ANYTHINGLLM_VERSION="${ANYTHINGLLM_VERSION:-1.7.2}"
VECTOR_DB="${VECTOR_DB:-lancedb}" # lancedb | qdrant
ANYTHINGLLM_PG_PASSWORD="${ANYTHINGLLM_PG_PASSWORD:-$(openssl rand -hex 24)}"
ANYTHINGLLM_AUTH_TOKEN="${ANYTHINGLLM_AUTH_TOKEN:-$(openssl rand -hex 32)}"
ANYTHINGLLM_JWT_SECRET="${ANYTHINGLLM_JWT_SECRET:-$(openssl rand -hex 32)}"
ANYTHINGLLM_SIG_KEY="${ANYTHINGLLM_SIG_KEY:-$(openssl rand -hex 32)}"
ANYTHINGLLM_SIG_SALT="${ANYTHINGLLM_SIG_SALT:-$(openssl rand -hex 32)}"
ANYTHINGLLM_QDRANT_API_KEY="${ANYTHINGLLM_QDRANT_API_KEY:-$(openssl rand -hex 32)}"
echo
echo "========================================"
echo "AnythingLLM 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-anythingllm.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-anythingllm.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 /opt/anythingllm"
mkdir -p /opt/anythingllm/storage /opt/anythingllm/hotdir /opt/anythingllm/outputs \
/var/lib/qdrant/storage /var/lib/qdrant/snapshots
chmod 700 /opt/anythingllm /var/lib/qdrant /var/lib/qdrant/storage /var/lib/qdrant/snapshots
# AnythingLLM image runs as uid 1000 by default
chown -R 1000:1000 /opt/anythingllm/storage /opt/anythingllm/hotdir /opt/anythingllm/outputs
cat > /opt/anythingllm/.env <<ENV
ANYTHINGLLM_VERSION=${ANYTHINGLLM_VERSION}
ANYTHINGLLM_DOMAIN=${ANYTHINGLLM_DOMAIN}
VECTOR_DB=${VECTOR_DB}
PG_PASSWORD=${ANYTHINGLLM_PG_PASSWORD}
AUTH_TOKEN=${ANYTHINGLLM_AUTH_TOKEN}
JWT_SECRET=${ANYTHINGLLM_JWT_SECRET}
SIG_KEY=${ANYTHINGLLM_SIG_KEY}
SIG_SALT=${ANYTHINGLLM_SIG_SALT}
QDRANT_API_KEY=${ANYTHINGLLM_QDRANT_API_KEY}
ENV
chmod 600 /opt/anythingllm/.env
cat > /opt/anythingllm/docker-compose.yml <<'COMPOSE'
services:
postgres:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_USER: anythingllm
POSTGRES_PASSWORD: ${PG_PASSWORD}
POSTGRES_DB: anythingllm
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U anythingllm -d anythingllm"]
interval: 30s
timeout: 5s
retries: 5
start_period: 20s
qdrant:
image: qdrant/qdrant:v1.12.4
restart: unless-stopped
profiles: ["qdrant"]
environment:
QDRANT__SERVICE__API_KEY: ${QDRANT_API_KEY}
QDRANT__TELEMETRY_DISABLED: "true"
volumes:
- /var/lib/qdrant/storage:/qdrant/storage
- /var/lib/qdrant/snapshots:/qdrant/snapshots
anythingllm:
image: mintplexlabs/anythingllm:${ANYTHINGLLM_VERSION}
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
cap_add:
- SYS_ADMIN
environment:
SERVER_PORT: 3001
STORAGE_DIR: /app/server/storage
DATABASE_CONNECTION_STRING: postgresql://anythingllm:${PG_PASSWORD}@postgres:5432/anythingllm
MULTI_USER_MODE: "true"
DISABLE_TELEMETRY: "true"
AUTH_TOKEN: ${AUTH_TOKEN}
JWT_SECRET: ${JWT_SECRET}
SIG_KEY: ${SIG_KEY}
SIG_SALT: ${SIG_SALT}
VECTOR_DB: ${VECTOR_DB}
QDRANT_ENDPOINT: http://qdrant:6333
QDRANT_API_KEY: ${QDRANT_API_KEY}
LANCEDB_PATH: /app/server/storage/lancedb
LLM_PROVIDER: openai
WHISPER_PROVIDER: local
TTS_PROVIDER: native
EMBEDDING_ENGINE: native
volumes:
- /opt/anythingllm/storage:/app/server/storage
- /opt/anythingllm/hotdir:/app/collector/hotdir
- /opt/anythingllm/outputs:/app/collector/outputs
ports:
- "127.0.0.1:3001:3001"
ulimits:
nofile:
soft: 64000
hard: 64000
volumes:
pgdata:
driver: local
COMPOSE
echo "==> Starting AnythingLLM stack (${VECTOR_DB})"
if [[ "${VECTOR_DB}" == "qdrant" ]]; then
docker compose --env-file /opt/anythingllm/.env --profile qdrant -f /opt/anythingllm/docker-compose.yml up -d
else
docker compose --env-file /opt/anythingllm/.env -f /opt/anythingllm/docker-compose.yml up -d
fi
echo "==> Waiting for AnythingLLM on 127.0.0.1:3001"
for i in {1..120}; do
if ss -lntp | grep -q '127.0.0.1:3001'; then
break
fi
sleep 2
done
if ! ss -lntp | grep -q '127.0.0.1:3001'; then
echo "AnythingLLM failed to listen on 127.0.0.1:3001"
docker compose -f /opt/anythingllm/docker-compose.yml logs --tail=200 anythingllm || true
exit 1
fi
echo "==> Installing nginx and certbot"
apt-get -y install nginx certbot python3-certbot-nginx
cat > /etc/nginx/sites-available/anythingllm <<NGINX
upstream anythingllm_backend {
server 127.0.0.1:3001;
keepalive 32;
}
server {
listen 80;
listen [::]:80;
server_name ${ANYTHINGLLM_DOMAIN};
return 301 https://\$host\$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name ${ANYTHINGLLM_DOMAIN};
client_max_body_size 500M;
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 SAMEORIGIN 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://anythingllm_backend;
}
}
NGINX
ln -sf /etc/nginx/sites-available/anythingllm /etc/nginx/sites-enabled/anythingllm
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 "${ANYTHINGLLM_EMAIL}" -d "${ANYTHINGLLM_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|3001|5432|6333)\b' || true
echo
echo "Containers:"
docker compose -f /opt/anythingllm/docker-compose.yml ps
echo
echo "Services:"
systemctl is-active docker nginx fail2ban chrony || true
echo
echo "Multi-user check (expect 401 without bearer):"
curl -sS -o /dev/null -w '%{http_code}\n' "https://${ANYTHINGLLM_DOMAIN}/api/system/check-token" || true
echo
echo "Secrets written to /opt/anythingllm/.env (mode 600). Move them to your secrets manager and remove the file from this host before going live."
echo "JWT_SECRET, SIG_KEY, and SIG_SALT MUST be persisted across redeploys. Rotating them invalidates every session and password reset link in flight."
echo
echo "Vector store: ${VECTOR_DB}"
if [[ "${VECTOR_DB}" == "qdrant" ]]; then
echo " Qdrant API key:"
echo " ${ANYTHINGLLM_QDRANT_API_KEY}"
echo " Snapshots: /var/lib/qdrant/snapshots"
else
echo " LanceDB on persistent volume: /opt/anythingllm/storage/lancedb"
echo " Make sure VM-level backup covers /opt/anythingllm/storage."
fi
echo
echo "Web UI:"
echo "https://${ANYTHINGLLM_DOMAIN}/"
echo
echo "First steps:"
echo "1. Open the URL — the first sign-up becomes the admin account."
echo "2. Settings -> Users -> Invite team members. One workspace per data-scoping boundary."
echo "3. Settings -> LLM Preference -> configure provider (OpenAI / Anthropic / local Ollama)."
echo "4. Upload first documents to a workspace; confirm retrieval is scoped to that workspace only."
Rendez-le exécutable et exécutez-le :
chmod 700 /root/setup-anythingllm-ubuntu22.sh
ANYTHINGLLM_DOMAIN=chat.example.com \
ANYTHINGLLM_EMAIL=ops@example.com \
VECTOR_DB=lancedb \
/root/setup-anythingllm-ubuntu22.sh
Le premier utilisateur qui s’inscrit à https://chat.example.com/ devient l’administrateur — réservez ce compte immédiatement, invitez le reste de l’équipe, et créez un espace de travail par frontière d’isolation de données (Exploitation, Contrats, RH). Les documents téléversés dans un espace de travail restent isolés à cet espace ; les requêtes inter-espaces ne sont pas silencieusement autorisées. Si vous réglez VECTOR_DB=qdrant, le script attache un sidecar Qdrant lié au réseau compose avec sa propre clé API et son répertoire de snapshots sous /var/lib/qdrant. Déplacez /opt/anythingllm/.env vers votre gestionnaire de secrets et confirmez que votre sauvegarde au niveau de la VM couvre /opt/anythingllm/storage — ce volume contient les documents, l’index LanceDB et le chemin de décharge Postgres.
Exploitez le AnythingLLM de production sur les machines virtuelles infogérées de Stack Harbor avec correctifs, supervision et escalade Sev-1 en place : Calcul cloud infogéré — ou démarrons la conversation si vous souhaitez qu’on planifie la migration ensemble.