Dify is an open-source platform for building LLM applications: chatbots, AI assistants, RAG knowledge bases and multi-step workflows, through a visual editor. It gives you prompt orchestration, model management across many providers, datasets, logs and annotations, and publishes apps as web pages or APIs. The community edition self-hosts with Docker Compose.
What you can build
- Chatbots and assistants grounded in your documents (knowledge base / RAG).
- Workflows: visual pipelines with LLM steps, conditions, code nodes, HTTP requests, and tools.
- Agents that call tools (search, APIs, custom tools).
- APIs: every app gets a REST API, so your website or backend can use it.
Requirements
- At least 2 vCPU and 4 GB RAM. 4 vCPU and 8 GB is more comfortable, because the stack runs about 10 containers (API, worker, web, PostgreSQL, Redis, a vector database, a sandbox, a plugin daemon, and Nginx).
- Docker and Docker Compose. See install Docker.
- API keys for the model providers you plan to use, or a local model server (Ollama, LocalAI, or vLLM on a GPU).
Install
git clone https://github.com/langgenius/dify.git /opt/dify
cd /opt/dify/docker
cp .env.example .env
Edit .env before the first start. Key values:
SECRET_KEY=<openssl rand -base64 42>
CONSOLE_API_URL=https://dify.example.com
APP_API_URL=https://dify.example.com
APP_WEB_URL=https://dify.example.com
SERVICE_API_URL=https://dify.example.com
DB_PASSWORD=<strong password>
REDIS_PASSWORD=<strong password>
VECTOR_STORE=weaviate # default; qdrant, pgvector, milvus and others are supported
EXPOSE_NGINX_PORT=8080 # move off port 80 if a host Nginx handles TLS
EXPOSE_NGINX_SSL_PORT=8443
Start it:
docker compose up -d
docker compose ps
Open http://<server>:8080/install (or via your domain) to create the admin account. Do this immediately, because whoever opens the install page first becomes the admin.
HTTPS with a host Nginx
Bind Dify’s Nginx to localhost (or firewall the port), and proxy to it:
server {
server_name dify.example.com;
client_max_body_size 100M;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_read_timeout 600s;
}
# listen 443 ssl; certbot --nginx -d dify.example.com
}
Alternatively, Dify’s own Nginx container can use Certbot (see the .env comments). See Let’s Encrypt.
Configure model providers
Settings → Model Provider: install the provider plugins you need (OpenAI, Anthropic, Gemini, Azure OpenAI, OpenRouter, Ollama, and OpenAI-API-compatible), enter keys, and set system default models for chat, embeddings and reranking. Local models: point the Ollama or OpenAI-compatible provider to your model server. From inside Docker, use the host’s address (not localhost). See LocalAI.
Knowledge bases (RAG)
- Knowledge → Create, and upload documents or sync from a website or Notion.
- Choose chunking (automatic or custom), the embedding model, and retrieval mode (vector, full-text, or hybrid with reranking, which noticeably improves answers).
- Attach the knowledge base to an app’s context, and test with the built-in retrieval testing.
See vector databases.
Security
- Create the admin account right after install, and invite team members with roles.
- The code sandbox runs user code. Keep it on the internal network, as shipped.
- Protect published apps and APIs: each app API key gives access to that app. Rate-limit public web apps.
- Keep
.envprivate (chmod 600). See secrets management.
Backups
Back up docker/volumes/ (PostgreSQL, Redis, vector DB, uploaded files) and .env. For consistency, stop the stack or dump PostgreSQL first:
cd /opt/dify/docker
docker compose exec db pg_dump -U postgres dify > /backups/dify-$(date +%F).sql
tar czf /backups/dify-volumes-$(date +%F).tar.gz volumes .env
Upgrades
cd /opt/dify/docker
git fetch && git checkout <new-release-tag>
# compare .env.example with your .env for new variables
docker compose pull && docker compose up -d
Read the release notes, since some versions require migration steps. Back up first. See updating self-hosted apps.
Quick reference
| Item | Value |
|---|---|
| Install dir | dify/docker |
| Config | .env (SECRET_KEY, URLs, ports, VECTOR_STORE) |
| First admin | /install |
| Data | docker/volumes/ |
| Minimum size | 2 vCPU / 4 GB RAM (8 GB recommended) |
Related: AnythingLLM, Flowise, and n8n.