Dify

Plan and deploy self-hosted Dify for LLM workflows, knowledge bases and agents in infrastructure you control, with model routing, sandboxing, access and backups covered.

On this page

Where self-hosted Dify fits in a private AI stack

Self-hosted Dify keeps app definitions, documents, conversation logs and provider credentials in your environment. The Dify README describes it as an open-source platform for agentic workflows and RAG pipelines that can run on cloud, in a VPC or self-hosted.

Teams use it to build chat assistants, workflows on a visual canvas, knowledge bases for retrieval-augmented generation, and agents that call tools, MCP servers or your own APIs. Every app is exposed through an API and can be published as a web app.

Dify does not run models. It calls hosted APIs or self-hosted runtimes such as vLLM and Ollama, often through a gateway such as LiteLLM. That makes it the layer where teams assemble prompts, documents and tools, and where data-handling rules for those apps are enforced.

The README lists three editions: Dify Cloud (hosted), Community Edition installed with Docker Compose, and Dify Enterprise. This page covers the self-hosted Community Edition and marks the points where Enterprise changes the plan.

Dify open source license and edition terms that shape the deployment

The Dify Open Source License is its own license built on Apache 2.0. Have counsel read the full text before designing a shared platform.

TermWhat the license or vendor statesDeployment effect
License baseThe license is a modified version of Apache License 2.0 with additional conditions. Apart from those conditions, all other rights and restrictions follow Apache License 2.0.Treat the added conditions as the part to review. Counsel should read them against your intended use.
Multi-tenant conditionCondition 1a says that, unless Dify authorizes it in writing, the source code may not be used to operate a multi-tenant environment. One tenant corresponds to one workspace.Separate workspaces per business unit or customer fall under this condition. Settle the workspace model early with counsel or Dify.
Logo and copyrightCondition 1b says the logo or copyright information in the Dify console or applications may not be removed or modified. It does not apply to uses that do not involve the Dify frontend, which is the web image when running with Docker.Published web apps keep Dify branding. A custom frontend built on the app APIs is outside this condition.
Enterprise editionThe README positions Dify Enterprise for organizations that need self-hosting, SSO, RBAC security and support SLAs, and it is requested through a sales contact form. The Dify Enterprise page lists SSO via SAML/OIDC, workflow-level RBAC, SCIM provisioning and tamper-evident audit logs streamed to a SIEM.If corporate SSO, SCIM or audit streaming is a requirement, choose the edition before building production apps.
Enterprise topologiesThe Enterprise page names Dify-managed (Dedicated), Customer-managed VPC and Air-gapped on-prem topologies. It also lists a Helm chart, Terraform modules, a named CSM and a 1-hour response on Sev-1.Match the topology to your network and procurement rules before comparing it with a Community build.
Vulnerability reportingSECURITY.md asks that suspected vulnerabilities be reported privately through GitHub Security Advisories, not through public issues, discussions or pull requests. It does not list supported versions.Set up an internal intake path for advisories and plan to stay close to the latest release.

Components in a self-hosted Dify deployment

The Docker Compose stack in the Dify repository defines these services, and the settings below come from the environment variable reference.

API, workers and Nginx

The API serves the console and app APIs, and Celery workers handle indexing and background jobs. Nginx fronts the web service on port 80 by default, changed with EXPOSE_NGINX_PORT. CELERY_WORKER_AMOUNT defaults to 4 and applies only when autoscaling is off.

Database and Redis

DB_TYPE defaults to postgresql, with mysql, oceanbase and seekdb supported. Dify does not migrate stored data if you change it. Redis can run in Sentinel mode through REDIS_USE_SENTINEL, which is mutually exclusive with Cluster mode.

Vector store and file storage

VECTOR_STORE defaults to weaviate, and existing knowledge bases keep using the vector database they were indexed in. STORAGE_TYPE defaults to opendal, with s3, azure-blob, google-storage and supabase also supported. The local type is listed as deprecated.

Code sandbox and SSRF proxy

The sandbox runs code for Code and Template nodes. The ssrf_proxy service carries outbound requests from Dify and blocks internal and private IP ranges. The default stack publishes no host ports for the database, Redis, sandbox or Weaviate.

Plugin daemon and Marketplace

Model providers and tools arrive as plugins. FORCE_VERIFYING_SIGNATURE defaults to true and requires valid signatures before install. MARKETPLACE_ENABLED defaults to true, and turning it off makes the API reject Marketplace installs and upgrades.

Dify docker compose install, Kubernetes and isolated network options

The Docker Compose guide lists these Dify system requirements: Docker with a running daemon, Docker Compose 2.35.0 or later, Git and OpenSSL, with at least 2 CPU cores and 4 GiB of RAM. On macOS, Docker Desktop needs a VM of at least 2 vCPUs and 8 GiB. On Windows, use Docker Desktop with WSL 2 and keep code and container data in the Linux file system. The install clones a release tag, copies docker/.env.example to .env, sets a sandbox token with openssl rand -hex 32 and runs docker compose up -d. It suits pilots and smaller deployments, where host backups and a tested restore carry the availability plan.

Connect Ollama, vLLM and other models and control what reaches them

Model providers install as plugins. Ollama has its own, and the OpenAI-API-compatible plugin can call vLLM or a LiteLLM gateway, which gives one place for keys, budgets and approved fallbacks. Knowledge bases also need an embedding model. Vectors from one embedding model cannot be searched with another, so changing it means re-indexing.

Prompt injection is the main application risk. Retrieved documents and tool outputs enter the model's context and can carry instructions. Give agents only the tools they need, put tools that write data behind narrow credentials or a Human Input step, and remember that anyone who can upload to a knowledge base can influence its answers.

Release 1.20.0 added opt-in malware scanning of knowledge uploads, per the release notes. FILE_SCAN_ENABLED defaults to false and must also be enabled per knowledge base. The policies for an unavailable scanner and for unscannable files default to blocking the file.

Decide log retention and whether traces may leave through integrations such as Langfuse. Write these rules down before the first app goes live, because they decide which model endpoints and plugins are approved.

Dify security hardening: change the shipped defaults before go-live

From the Docker Compose guide, the environment variable reference and the release notes.

AreaDefault or behaviorAction
First-time setupThe /install page creates the first admin account. INIT_PASSWORD defaults to empty, gates that page when set, has no effect after setup and has a maximum length of 30 characters.Set INIT_PASSWORD so nobody else can claim the admin account. Leave ALLOW_REGISTER at its default of false for an invite-only deployment, since invitations and the setup wizard still work.
SECRET_KEYIt defaults to empty. Dify then reuses a key saved in storage or generates and saves one. It signs authentication tokens and file URLs and encrypts system-level OAuth client credentials.The guide says to leave it unset unless you have a reason, because changing it later invalidates signed tokens and file links. If you set it, store it in a secret manager and never change it casually.
Bundled credentialsThe stack ships development credentials, including DB_PASSWORD, REDIS_PASSWORD, SANDBOX_API_KEY, WEAVIATE_API_KEY, PLUGIN_DAEMON_KEY, PLUGIN_DIFY_INNER_API_KEY, DIFY_AGENT_API_TOKEN and DIFY_AGENT_SERVER_SECRET_KEY.Replace each one. SANDBOX_API_KEY defaults to dify-sandbox and must match CODE_EXECUTION_API_KEY, or Code and Template nodes fail with HTTP 401.
HTTPS and exposureThe default stack publishes no host ports for the database, Redis, sandbox or Weaviate. Nginx listens on port 80 by default.Configure HTTPS before others can reach the deployment. Keep data stores off public interfaces. Release 1.18.0 notes that bundled Nginx now replaces X-Forwarded-For, so check your proxy chain.
Outbound access and sandboxThe SSRF proxy blocks requests to internal and private IP ranges. SANDBOX_ENABLE_NETWORK defaults to true, and setting it to false makes Code nodes, Template nodes, Jinja2 prompts and the built-in Code tool fail.Allowlist only the internal hosts that tools need. Keep sandbox networking on when apps use those nodes, and limit egress at the network layer.
PluginsSignature checks are on by default, and Marketplace installs are on by default.Approve plugins through review. Disable the Marketplace in isolated networks and install reviewed packages from files.
Defaults that changed in releasesRelease 1.17.0 added Turnstile CAPTCHA on login and email-code attempt limits. Release 1.20.0 changed the defaults of OPENAPI_ENABLED and NEXT_PUBLIC_ENABLE_HITL_IM to true.Read each release note you cross and set these values on purpose instead of inheriting them.

Dify backup and restore and upgrade guide

What needs to be backed up for Dify backup and restore?

Back up docker/.env, local service .env files, custom Compose files and docker/volumes/, plus the database and vector store. Add the local_sandbox named volumes mounted at /home/dify and /workspace. If you use object storage, back that up too. Take everything together, because stored credentials cannot be decrypted without the matching key material.

How do we rehearse a restore?

Restore onto an isolated host at the same version. Check that long-running services show Up or healthy and that init_permissions shows Exited (0). Then call a model with a stored credential, query a knowledge base and run a workflow with a code node. Record the result, since the test record is the evidence that the backup works.

What is the documented Dify upgrade guide for Compose?

Back up the files and volumes first. Run git fetch --tags origin and git checkout the target version. Compare .env.example with your files, then run docker compose config --quiet, pull and up -d. Use up -d instead of restart so new environment values apply. Read the target release's upgrade guide before you start.

Which settings must stay fixed during an upgrade?

Keep your existing database, vector store and profiles. Changing DB_TYPE or VECTOR_STORE does not migrate data. The 1.20.0 upgrade notes say to keep SECRET_KEY, any configured PASSWORD_PEPPER and the local sandbox token unchanged. Treat these as part of the backup set so a rollback restores a consistent state.

Which past releases needed extra steps?

Release 1.17.0 renamed EDITION to DEPLOYMENT_EDITION, and the old variable is no longer read. Release 1.17.1 required deployments with bundled Weaviate to do a staged upgrade (1.27.0 to 1.39.2) first, or vector search can break. Release 1.18.0 requires a non-empty auth token for local Agent sandboxes.

How often should we plan upgrades?

The releases page shows v1.20.0 on November 18, with 1.19.0 (04 Nov), 1.18.0 (23 Oct), 1.17.1 (10 Sep) and 1.17.0 (25 Aug) before it. That is a release every two to six weeks. Release 1.19.0 states that Docker Compose 2.35.0 or later is required, so check host tooling too. Schedule a regular upgrade window.

Dify operating ownership

Dify sits between model owners, operators and app builders, so each part needs a named owner.

Platform team

  • Runs services, data stores and the plugin daemon.
  • Backs up database, storage and vectors together.
  • Applies environment changes at each upgrade.

Model owners

  • Approve providers, embedding models and routes.
  • Decide which plugins and tools may be installed.

Security

  • Holds SECRET_KEY and provider credentials.
  • Reviews SSRF allowlists and published web apps.
  • Tests agents for prompt injection.

App builders

  • Own prompts, workflows and knowledge bases.
  • Export key apps as DSL files into version control.

Dify self-hosted deployment questions

Can the community edition use SSO with SAML or OIDC?

OIDC and SAML SSO are Enterprise features. The community edition documents email and password, email code, and GitHub or Google sign-in. If your identity provider is a firm requirement, decide on the Dify enterprise edition before production apps are built, since the edition choice affects the access design.

What are the Dify system requirements?

The Compose guide requires Docker with a running daemon, Docker Compose 2.35.0 or later, Git and OpenSSL, with at least 2 CPU cores and 4 GiB of RAM. macOS Docker Desktop needs a VM of at least 2 vCPUs and 8 GiB. Windows needs Docker Desktop with WSL 2. Production sizing depends on measured load.

Is there a Dify Kubernetes Helm chart?

The Enterprise page lists a Helm chart for Kubernetes and Terraform modules. The Community Edition guide is built around Docker Compose. For a Community install on Kubernetes, you review and own the chart or manifests, run replicated state services and run migrations from one job per upgrade.

Can each department get its own workspace under the multi-tenant license?

The license counts each workspace as a tenant and requires written authorization from Dify to operate a multi-tenant environment. Review the workspace model with counsel or Dify first. Do this before departments start building, because moving apps afterward is harder than choosing the model early.

How do we move apps between instances?

Apps export and import as DSL files. Provider credentials and knowledge base contents are set up separately on the target. Keep exported DSL files in version control so app changes are reviewed, and rebuild knowledge bases on the target with the same embedding model.

How do we report a security issue in Dify?

SECURITY.md asks that suspected vulnerabilities be reported privately through GitHub Security Advisories, not through public issues, discussions or pull requests. It does not list supported versions, so plan to track current releases and read each release note when you upgrade.

Scope and handover for a Dify deployment

Effort depends on the edition and workspace model, the number of model providers, knowledge base volume, availability targets and isolated network requirements. Agreeing data-handling rules for prompts, documents and logs often takes longer than installing the stack.

DeployOpen deploys Dify in your cloud account, data center or isolated network, connects approved model runtimes, replaces shipped secrets, configures the SSRF proxy and sandbox, integrates SSO where your edition supports it, and sets up backups with a restore rehearsal. We can also test published apps and agents for prompt injection as part of AI security testing.

Handover includes the edition decision, configuration in version control, the model and plugin register, the restore test record and named owners.

Sources and further reading

More on Dify

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.