1. Prepare the Server
On Ubuntu 24.04, secure the server and install Docker (Dify asks for Compose 2.35.0 or later; docker compose version shows yours), plus Git and OpenSSL. Point a domain at the server for HTTPS later.
Until the administrator account exists, whoever opens the setup page first can create it. If you turned on the firewall on your server's page in the dashboard, allow ports 80 and 443 only from your own address for now. That firewall sits outside the server, so Docker cannot open a way round it.
2. Download a Release and Configure It
Pick the newest tag on Dify's GitHub releases page and use it in place of 1.x.y:
git clone --branch 1.x.y --depth 1 https://github.com/langgenius/dify.git cd dify/docker cp .env.example .env openssl rand -hex 32 # run once for each secret below
In .env, set DIFY_AGENT_LOCAL_SANDBOX_AUTH_TOKEN to a random value; the agent backend does not start without it. Then replace the development credentials Dify ships with, each with its own random value: DB_PASSWORD, REDIS_PASSWORD, SANDBOX_API_KEY, CODE_EXECUTION_API_KEY, WEAVIATE_API_KEY, PLUGIN_DAEMON_KEY, PLUGIN_DIFY_INNER_API_KEY and DIFY_AGENT_API_TOKEN. Do it before the first start, as the databases keep the passwords they were created with.
3. Start It and Create the Administrator
docker compose up -d docker compose ps --all # init_permissions should show Exited (0); the rest Up
Open http://203.0.113.10/install (your server's address), create the administrator account, then sign in at http://203.0.113.10. Only Dify's Nginx publishes ports, 80 by default; the database, Redis, sandbox and vector store stay inside Docker.
4. Turn On HTTPS
Dify's bundled Nginx can serve HTTPS: NGINX_HTTPS_ENABLED and the certificate and certbot settings in .env control it, and Dify's HTTPS documentation for your version gives the steps. Set the public URLs in its URL settings to https:// addresses too: the docs note that secure cookies need both the console API and web URLs to start with https://. Once it works, open ports 80 and 443 to everyone who should use it.
After changing .env, apply it with docker compose up -d, not docker compose restart.
5. Connect Models
Under Integrations → Model Provider, add a provider's API key, or a provider for a model you host. Keeping the model on your own hardware keeps prompts and documents off third-party services: a GPU server running vLLM or Ollama can serve several Dify apps at once.
Upgrades and Backups
Back up .env and the docker/volumes/ folder first, read the release's upgrade notes, then:
cd dify/docker docker compose stop git fetch --tags origin git checkout 1.x.z # the new release tag docker compose config --quiet docker compose pull docker compose up -d docker compose ps --all
Never copy .env.example over your .env during an upgrade; it would wipe your settings. Nightly, copy docker/volumes/ and .env off the server with Borg to a storage box. For simpler automations without the AI app builder, n8n may be enough; for search over your own vectors, see Qdrant.