smart_ide/docs/services.md
Nicolas Cantu c4215044f0 Re-enable nginx Bearer auth on ia.enso /ollama
**Motivations:**
- Restore gate on /ollama/; document Cursor streamFromAgentBackend note.

**Root causes:**
- N/A.

**Correctifs:**
- location /ollama/ if map + clear Authorization upstream; deploy script emits Bearer + websocket maps with retry bearer_only.

**Evolutions:**
- README Cursor subsection on streamFromAgentBackend (observed behavior); feature/services/infrastructure aligned.

**Pages affectées:**
- deploy/nginx/sites/ia.enso.4nkweb.com.conf
- deploy/nginx/deploy-ia-enso-to-proxy.sh
- deploy/nginx/README-ia-enso.md
- deploy/nginx/http-maps/ia-enso-ollama-bearer.map.conf.example
- docs/features/ia-enso-nginx-proxy-ollama-anythingllm.md
- docs/services.md
- docs/infrastructure.md
2026-03-23 07:49:06 +01:00

112 lines
5.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Services
## Systemd (local host)
- **Ollama:** `ollama.service` (official installer). Optional drop-in `OLLAMA_HOST=0.0.0.0:11434` for Docker — see `configure-ollama-for-docker.sh` and [systemd/README.md](../systemd/README.md).
- **AnythingLLM:** `anythingllm.service` — Docker container managed by systemd. Install: `sudo ./scripts/install-systemd-services.sh`. Config: `/etc/default/anythingllm` (template `systemd/anythingllm.default`).
```bash
sudo systemctl restart ollama anythingllm
sudo systemctl status ollama anythingllm
```
## Where these services run (first deployment)
For the **first deployment target**, Ollama and AnythingLLM run on the **remote SSH server** that hosts the AI stack and repositories, not necessarily on the users Linux laptop. Access from the client may use **SSH local forwarding** or internal hostnames. See [deployment-target.md](./deployment-target.md).
## Overview
| Service | Delivery | Default URL / port | Config / persistence |
|---------|----------|--------------------|------------------------|
| Ollama | systemd (`ollama.service`) | `http://127.0.0.1:11434` (API) | Models under Ollama data dir; listen address via systemd override |
| AnythingLLM | Docker (`mintplexlabs/anythingllm`) | `http://localhost:3001` | `$HOME/anythingllm` + `.env` bind-mounted ; **one workspace per project** (see [anythingllm-workspaces.md](./anythingllm-workspaces.md)) |
| AnythingLLM Desktop | AppImage (optional) | local Electron app | User profile under `~/.config/anythingllm-desktop` (installer) |
## Ollama
- **Install:** official script `https://ollama.com/install.sh` (used on target Ubuntu hosts).
- **Service:** `systemctl enable --now ollama` (handled by installer).
- **Default bind:** loopback only (`127.0.0.1:11434`), which **blocks** Docker containers on the same host from calling Ollama.
### Expose Ollama to Docker on the same host
Run **`configure-ollama-for-docker.sh`** as root (or equivalent):
- Drop-in: `/etc/systemd/system/ollama.service.d/override.conf`
- `Environment="OLLAMA_HOST=0.0.0.0:11434"`
- `systemctl daemon-reload && systemctl restart ollama`
Verify: `ss -tlnp | grep 11434` shows `*:11434`.
### Models (reference)
- Embeddings for AnythingLLM + Ollama: `ollama pull nomic-embed-text`
- Custom name **`qwen3-code-webdev`:** not in the public Ollama library as-is; this repo includes `Modelfile-qwen3-code-webdev` defining an alias (default base: `qwen3-coder:480b-cloud`). Rebuild with `ollama create qwen3-code-webdev -f Modelfile-qwen3-code-webdev` after editing `FROM`.
## AnythingLLM (Docker)
### Workspaces and projects
AnythingLLM is used with **dedicated workspaces per project** so RAG memory, documents, and threads stay isolated. A **sync job** (“moulinette”) keeps selected repository files aligned with each workspace. Operational rules: [anythingllm-workspaces.md](./anythingllm-workspaces.md).
**Script:** `install-anythingllm-docker.sh`
- **Image:** `mintplexlabs/anythingllm` (override with `ANYTHINGLLM_IMAGE`).
- **Container name:** `anythingllm` (override with `ANYTHINGLLM_CONTAINER_NAME`).
- **Ports:** `HOST_PORT:3001` (default `3001:3001`).
- **Capabilities:** `--cap-add SYS_ADMIN` (Chromium / document features in container).
- **Networking:** `--add-host=host.docker.internal:host-gateway` so the app can reach Ollama on the host at `http://host.docker.internal:11434` once `OLLAMA_HOST` is set as above.
- **Volumes:**
- `${STORAGE_LOCATION}:/app/server/storage`
- `${STORAGE_LOCATION}/.env:/app/server/.env`
Re-running the script **removes** the existing container by name and starts a new one; data remains in `STORAGE_LOCATION` if the bind path is unchanged.
### Configure LLM provider (Ollama)
In `$STORAGE_LOCATION/.env` (mounted into the container), set at minimum:
- `LLM_PROVIDER='ollama'`
- `OLLAMA_BASE_PATH='http://host.docker.internal:11434'`
- `OLLAMA_MODEL_PREF='<model name>'` (e.g. `qwen3-code-webdev`)
- `EMBEDDING_ENGINE='ollama'`
- `EMBEDDING_BASE_PATH='http://host.docker.internal:11434'`
- `EMBEDDING_MODEL_PREF='nomic-embed-text:latest'`
- `VECTOR_DB='lancedb'` (default stack)
See upstream `.env.example`:
<https://raw.githubusercontent.com/Mintplex-Labs/anything-llm/master/docker/.env.example>
After editing `.env`, restart the container: `docker restart anythingllm`.
## AnythingLLM Desktop (AppImage)
**Script:** `installer.sh` — downloads the official AppImage, optional AppArmor profile, `.desktop` entry. Interactive prompts; not a headless service.
- Documentation: <https://docs.anythingllm.com>
- Use **either** Docker **or** Desktop on the same machine if you want to avoid conflicting ports and duplicate workspaces.
## Operational checks
```bash
systemctl is-active ollama
curl -sS http://127.0.0.1:11434/api/tags | head
docker ps --filter name=anythingllm
docker exec anythingllm sh -c 'curl -sS http://host.docker.internal:11434/api/tags | head'
```
The last command must succeed after `OLLAMA_HOST=0.0.0.0:11434` and `host.docker.internal` are configured.
## Public reverse proxy (ia.enso.4nkweb.com)
When Ollama runs on a LAN host (e.g. `192.168.1.164` via `IA_ENSO_BACKEND_IP` / `deploy/nginx/sites/ia.enso.4nkweb.com.conf`) and must be reached via the **proxy** with HTTPS and a **Bearer** gate on `/ollama/`, use `deploy/nginx/` and **[deploy/nginx/README-ia-enso.md](../deploy/nginx/README-ia-enso.md)** (script `deploy-ia-enso-to-proxy.sh`, checks, troubleshooting).
**Full URLs**
- AnythingLLM UI: `https://ia.enso.4nkweb.com/anythingllm/`
- Ollama native API example: `https://ia.enso.4nkweb.com/ollama/api/tags` (header `Authorization: Bearer <secret>`)
- Cursor / OpenAI-compatible base URL: `https://ia.enso.4nkweb.com/ollama/v1`
- Cursor API key: same value as the Bearer secret in nginx `map`
Feature note: [ia-enso-nginx-proxy-ollama-anythingllm.md](./features/ia-enso-nginx-proxy-ollama-anythingllm.md).