Self-host Dify
Build and publish AI apps and workflows. Models without API keys.
Shelley handles the setup. About 15 minutes. Needs a 40 GB disk: Shelley sends you a link to grow it.
Prefer a terminal?
curl -fsSL https://exe.dev/deploy/dify/prompt.txt | ssh exe.dev new --disk=40GB --prompt=/dev/stdinDify is an open-source workbench for AI apps: chatbots, workflows, and agents built on a canvas, with knowledge bases for your documents. Each app publishes as a web page, an API, and an MCP server.
On exe.dev the console stays private behind your login, and published apps get a port of their own that you can make public. Models come from exe.dev's LLM gateway with no API keys, and workflows can call your other exe.dev integrations, so no credentials are stored in Dify.
What you get#
- Dify 1.19 in Docker Compose with its own generated secrets in
~/dify/docker/.env(mode 600), coming back after a reboot. - The console at
https://<vm>.exe.xyz:8080/, with you as admin, signed in with your exe.dev email. - OpenAI and Anthropic models from exe.dev's LLM gateway, with no API keys.
- A published sample chatbot answering through port 8000, which serves apps and the API but not the console.
- Workflows that can call your exe.dev integrations, with no credentials stored in Dify.
- Nightly backups of the databases, files, and vectors into
~/dify-backups, with one checked.
What's running, and where
https://my-dify.exe.xyz:8080/
The Dify console, after exe.dev login and Dify's own sign-in
https://my-dify.exe.xyz/
Published web apps and the API (/v1); make it public for customers and outside servers
Deploy with Shelley#
Click Deploy and Shelley will set up Dify on a new VM, then check that it works. No config-file wrangling required.
Dify needs a 40 GB disk, more than a new VM has. Shelley checks first and, if it's too small, gives you a link to grow it; the terminal command below makes the VM that size from the start.
Prefer a terminal?
curl -fsSL \
https://exe.dev/deploy/dify/prompt.txt \
| ssh exe.dev new --disk=40GB --prompt=/dev/stdinWhat Shelley is told
Set up Dify on this VM by following the exe.dev recipe at https://exe.dev/deploy/dify.md from top to bottom.
The recipe's example VM name is my-dify. This VM's name is the output of `hostname`: use it wherever the recipe writes my-dify. Skip the step that creates the VM; you are on it.
This recipe needs a 40GB disk, and a new VM's may be smaller. Before you install anything, run `df -h /`. If its size is under 36G, stop and ask me to grow the disk, either with this link: https://exe.dev/suggest?command=resize%20my-dify%20--disk%3D40GB or, on my computer, with `ssh exe.dev resize my-dify --disk=40GB`. When I say it's done, run `sudo resize2fs "$(findmnt -no SOURCE /)"`, check `df -h /` again, and carry on.
You are done when all of these are true. Check each one yourself:
- Dify 1.19 in Docker Compose with its own generated secrets in `~/dify/docker/.env` (mode 600), coming back after a reboot.
- The console at `https://<vm>.exe.xyz:8080/`, with you as admin, signed in with your exe.dev email.
- OpenAI and Anthropic models from exe.dev's LLM gateway, with no API keys.
- A published sample chatbot answering through port 8000, which serves apps and the API but not the console.
- Workflows that can call your exe.dev integrations, with no credentials stored in Dify.
- Nightly backups of the databases, files, and vectors into `~/dify-backups`, with one checked.
Read the whole recipe, including the closed details. For initial setup,
follow "Install by hand" first, skipping VM creation and SSH but not the
disk check, through "Test a backup". The walkthrough at the top is for
the owner afterwards. Do not run Restore unless the user asks.
Never print ~/dify/docker/.env or ~/dify-admin-password into the chat;
tell the owner where the password is. Don't share the VM or make it
public: the owner decides. Leave the Helpdesk bot app in place so the
owner can see it. The API takes a few minutes to start on a 2-CPU VM;
502 errors from nginx in that time are normal.
Finish with the URLs I should open.
Also at /deploy/dify/prompt.txt. The recipe it follows is /deploy/dify.md.
Open the console#
Open https://my-dify.exe.xyz:8080/ and sign in with your exe.dev email and
the password in ~/dify-admin-password on the VM. Change it under your
name → Account.
Models and integrations#
OpenAI and Anthropic models are ready in Integrations → Model Provider,
pointed at the gateway with a placeholder key. To connect them again, use
any key and the base URL https://llm.int.exe.xyz/v1 (OpenAI) or
https://llm.int.exe.xyz (Anthropic).
HTTP Request nodes can call your integrations at
https://<name>.int.exe.xyz; exe.dev adds the credentials on the way out.
Warning
Anyone who can edit workflows uses your models and integrations as you. Invite only people you'd trust with those credentials.
Build and publish an app#
Studio has a sample chatflow, Helpdesk bot. Edit it, try it in
Preview, then Publish. Its Access Point page lists the web app
and the API, both at https://my-dify.exe.xyz/.
Go public#
When an app is ready for customers, run this on your computer:
ssh exe.dev share set-public my-dify
That opens port 8000: web apps, the API (still behind app keys), MCP, and
webhooks. The console stays on port 8080, which is always private.
share set-private closes it again.
Warning
Public apps chat on your LLM allocation. Watch each app's Logs.
Bring your team#
Share the VM with ssh exe.dev share add my-dify teammate@example.com, then
invite them in Settings → Members. Without email set up, Dify shows an
invitation link to send yourself.
Keep your work#
Backups run nightly into ~/dify-backups, .env secrets included. Copy
them off the VM with scp -r my-dify.exe.xyz:dify-backups .. To update
Dify, back up, then ask Shelley or follow Dify's
upgrade steps;
the changes from this page live in files updates don't touch.
The nuts and bolts#
Happy clicking Deploy? You can stop here. These are the same setup steps Shelley follows, plus the maintenance commands for later.
Install by hand
Create a VM#
On your computer (pick another name if my-dify is taken):
ssh exe.dev new --name=my-dify --disk=40GB
ssh my-dify.exe.xyz
All remaining installation commands run on the VM, as exedev.
Commands use hostname, so your VM can have any name.
Room on the disk#
Check the disk:
df -h /
If Size is under 38G, the VM was made with a smaller disk. Grow it with
this link
(with your VM's name), or on your computer with
ssh exe.dev resize my-dify --disk=40GB. Then, back on the VM, grow the
filesystem to match:
sudo resize2fs "$(findmnt -no SOURCE /)"
df -h /
Get Docker ready#
Enable Docker at boot, or exe.dev's on-demand Docker won't start Dify after a reboot. Dify needs Docker Compose 2.35 or newer:
sudo systemctl enable --now docker.service
systemctl is-enabled docker.service
docker compose version
Expect enabled and a version of 2.35 or later.
Download Dify#
Dify's Compose setup lives in the docker directory of its repository.
Clone the 1.19.0 release:
git clone -q -c advice.detachedHead=false --branch 1.19.0 --depth 1 \
https://github.com/langgenius/dify.git ~/dify
cd ~/dify/docker
git describe --tags
Expect 1.19.0.
Configure it for exe.dev#
Dify reads .env in ~/dify/docker, on top of defaults in envs/. This
writes it once, starting from Dify's example: it moves Dify's nginx to
port 8080 for the console, tells Dify which addresses people use, replaces
the bundled default passwords with generated ones, and lets workflows reach
exe.dev integrations, which Dify's SSRF proxy would otherwise block as
private addresses.
cd ~/dify/docker
if [ ! -e .env ]; then
cp .env.example .env && chmod 600 .env
sed -i "s/^DIFY_AGENT_LOCAL_SANDBOX_AUTH_TOKEN=.*/DIFY_AGENT_LOCAL_SANDBOX_AUTH_TOKEN=$(openssl rand -hex 32)/" .env
host=$(hostname).exe.xyz
sandbox_key=$(openssl rand -hex 32)
weaviate_key=$(openssl rand -hex 32)
cat >> .env <<EOF
# exe.dev: the console on port 8080 (always private); published apps and
# the API on port 8000, the port https://$host/ reaches.
EXPOSE_NGINX_PORT=8080
CONSOLE_API_URL=https://$host:8080
CONSOLE_WEB_URL=https://$host:8080
NEXT_PUBLIC_SOCKET_URL=wss://$host:8080
APP_API_URL=https://$host
APP_WEB_URL=https://$host
SERVICE_API_URL=https://$host
FILES_URL=https://$host
TRIGGER_URL=https://$host
ENDPOINT_URL_TEMPLATE=https://$host/e/{hook_id}
# Replace the bundled default credentials.
DB_PASSWORD=$(openssl rand -hex 24)
REDIS_PASSWORD=$(openssl rand -hex 24)
PLUGIN_DAEMON_KEY=$(openssl rand -hex 32)
PLUGIN_DIFY_INNER_API_KEY=$(openssl rand -hex 32)
SANDBOX_API_KEY=$sandbox_key
CODE_EXECUTION_API_KEY=$sandbox_key
WEAVIATE_API_KEY=$weaviate_key
WEAVIATE_AUTHENTICATION_APIKEY_ALLOWED_KEYS=$weaviate_key
# Let workflows reach exe.dev integrations through Dify's SSRF proxy.
SSRF_PROXY_ALLOW_PRIVATE_DOMAINS=.int.exe.xyz
EOF
fi
grep -E '^(EXPOSE_NGINX_PORT|CONSOLE_WEB_URL|APP_WEB_URL)=' .env
Expect port 8080 and your VM's address, with and without :8080.
Add the apps-and-API port#
A second server in Dify's nginx answers on port 8000 with only what
published apps need: the web app pages, /api, /v1, /files, /mcp,
/triggers, and plugin endpoints under /e/. Read
exe-public.conf to see
exactly which paths. Dify's nginx loads every file in nginx/conf.d, and
Compose merges docker-compose.override.yaml into Dify's file, so neither
changes anything Dify ships:
cd ~/dify/docker
curl -fsSL https://exe.dev/deploy/dify/exe-public.conf -o nginx/conf.d/exe-public.conf
cat > docker-compose.override.yaml <<'EOF'
# exe.dev: publish the apps-and-API server from nginx/conf.d/exe-public.conf.
services:
nginx:
ports:
- "8000:8000"
EOF
docker compose config --quiet && echo ok
Start Dify#
Dify 1.19.0's plugin daemon runs as user 1001 but can't create its own
storage directory (dify#45597),
so plugin installs fail with mkdir /app/storage/assets: permission denied.
Create it first, then pull the images (about 12 GB) and start everything:
cd ~/dify/docker
mkdir -p volumes/plugin_daemon && sudo chown -R 1001:1001 volumes/plugin_daemon
docker compose pull -q
docker compose up -d
until curl -fs http://localhost:8080/console/api/setup; do sleep 10; done; echo
docker compose ps --format 'table {{.Service}}\t{{.Status}}'
The pull takes a few minutes. The API then runs its database migrations,
which take two or three minutes on 2 CPUs; the loop ends with
{"step":"not_started"...}. Every service should be Up.
Make yourself the admin#
Dify's first account owns the workspace. The VM is private, so nobody else can reach the setup page, but create the account now. Use your exe.dev email from the reflection integration, and a generated password:
owner=$(curl -fsS https://reflection.int.exe.xyz/email | jq -r '.email // empty')
echo "$owner"
If that prints nothing, set it yourself: owner=you@example.com. Then:
(umask 077; printf 'exe%s1\n' "$(openssl rand -hex 10)" > ~/dify-admin-password)
jq -n --arg email "$owner" --arg name "${owner%%@*}" --rawfile pw ~/dify-admin-password \
'{email: $email, name: $name[0:30], password: ($pw | rtrimstr("\n"))}' \
| curl -fsS http://localhost:8080/console/api/setup -H 'Content-Type: application/json' -d @-
echo
curl -fsS http://localhost:8080/console/api/setup; echo
Expect {"result":"success"}, then "step":"finished".
Connect the LLM gateway#
setup-models.sh signs in as
you, installs the OpenAI and Anthropic plugins from Dify's marketplace,
points them at https://llm.int.exe.xyz, and sets the default models.
It's what you'd click through in Integrations → Model Provider:
cd ~
curl -fsSLO https://exe.dev/deploy/dify/setup-models.sh
DIFY_EMAIL="$owner" bash setup-models.sh
Plugins take a minute to install. Expect both providers to end active.
Check it works#
sample-app.sh imports the Helpdesk bot, publishes it, makes an API key, and asks it a question through port 8000:
cd ~
curl -fsSLO https://exe.dev/deploy/dify/sample-app.sh
curl -fsSLO https://exe.dev/deploy/dify/helpdesk-bot.yml
DIFY_EMAIL="$owner" bash sample-app.sh helpdesk-bot.yml
Expect the web app's address and an answer about 30-day returns. Then check that port 8000 hides the console while port 8080 serves it:
for port in 8000 8080; do
curl -s -o /dev/null -w "$port: %{http_code}\n" http://localhost:$port/console/api/setup
done
Expect 8000: 404 and 8080: 200. Last, check that workflows reach
exe.dev integrations through Dify's SSRF proxy:
cd ~/dify/docker
docker compose exec -T api python -c 'import urllib.request as u
proxy = u.ProxyHandler({"https": "http://ssrf_proxy:3128"})
print(u.build_opener(proxy).open("https://llm.int.exe.xyz/models.json").status)'
Expect 200.
Set up nightly backups#
backup.sh dumps both PostgreSQL databases while Dify runs, pauses Weaviate for a few seconds to copy the vectors, and packs the file volumes and your configuration into one tarball. It keeps the newest 14.
curl -fsSL https://exe.dev/deploy/dify/backup.sh -o ~/dify-backup.sh
chmod +x ~/dify-backup.sh
sudo tee /etc/systemd/system/dify-backup.service >/dev/null <<EOF
[Unit]
Description=Back up Dify to ~/dify-backups
Requires=docker.service
After=docker.service
[Service]
Type=oneshot
Environment=DIFY_DIR=$HOME/dify/docker
ExecStart=$HOME/dify-backup.sh
EOF
sudo tee /etc/systemd/system/dify-backup.timer >/dev/null <<'EOF'
[Unit]
Description=Back up Dify every night
[Timer]
OnCalendar=*-*-* 03:30:00
RandomizedDelaySec=30m
Persistent=true
[Install]
WantedBy=timers.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable --now dify-backup.timer
sudo systemctl start dify-backup.service
systemctl list-timers dify-backup.timer
ls -lh ~/dify-backups
Check that the timer has a next run and the directory has a tarball. For
failures: journalctl -u dify-backup.service.
Test a backup#
Unpack the newest backup in a scratch directory and load its database dump into a throwaway PostgreSQL, without touching the running one:
latest=$(ls -1t ~/dify-backups/dify-*.tar.gz | head -n 1)
mkdir /tmp/dify-restore-test && cd /tmp/dify-restore-test
tar -xzf "$latest"
tar -tzf volumes.tar.gz | grep -c .
tar -tzf config.tar.gz
docker run -d --name dify-restore-test -e POSTGRES_PASSWORD=test postgres:15-alpine
until docker exec dify-restore-test pg_isready -U postgres -q; do sleep 1; done; sleep 2
gunzip -c postgres.sql.gz | docker exec -i dify-restore-test psql -q -U postgres -o /dev/null 2>&1 \
| grep -Ev 'NOTICE|already exists|cannot (drop|be dropped)' || true
docker exec dify-restore-test psql -U postgres -d dify -tAc 'select name from apps'
docker exec dify-restore-test psql -U postgres -d dify_plugin -tAc 'select plugin_id from plugins'
Expect a count of files, the three configuration files, Helpdesk bot,
and the two plugins. Remove only the scratch copy:
docker rm -f dify-restore-test
cd ~ && rm -rf /tmp/dify-restore-test
Installation done. Leave sharing to the owner; continue with Open the console.
Back up and restore
On the VM, sudo DIFY_DIR=$HOME/dify/docker ~/dify-backup.sh makes an
extra backup and prints its path. Copy backups off the VM as shown in
Keep your work.
Restore#
On a new VM, follow Install by hand through Download Dify, with the Dify version the backup came from. Then copy the backup over from your computer:
scp dify-20261116-033012.tar.gz my-dify.exe.xyz:
Use your backup's actual filename here and below. All remaining commands run on the VM. If Dify already runs there, stop it and keep its directory aside first, and download the same release again:
cd ~/dify/docker && docker compose down
sudo mv ~/dify ~/dify.before-restore
git clone -q -c advice.detachedHead=false --branch 1.19.0 --depth 1 \
https://github.com/langgenius/dify.git ~/dify
Unpack the configuration and files, and fix the addresses if the VM's name changed:
mkdir -p /tmp/dify-restore && cd /tmp/dify-restore
tar -xzf ~/dify-20261116-033012.tar.gz
cd ~/dify/docker
tar -xzf /tmp/dify-restore/config.tar.gz
sudo tar -xzf /tmp/dify-restore/volumes.tar.gz
old=$(sed -n 's|^APP_WEB_URL=https://||p' .env)
sed -i "s|$old|$(hostname).exe.xyz|g" .env
grep -E '^(CONSOLE_WEB_URL|APP_WEB_URL)=' .env
Load the databases into a fresh PostgreSQL, then start the rest:
cd ~/dify/docker
docker compose up -d --wait db_postgres
gunzip -c /tmp/dify-restore/postgres.sql.gz \
| docker compose exec -T db_postgres psql -q -U postgres -d postgres -o /dev/null
docker compose up -d
until curl -fs http://localhost:8080/console/api/setup; do sleep 10; done; echo
rm -rf /tmp/dify-restore
A few NOTICE, already exists, and cannot be dropped messages are
normal. Expect "step":"finished", then sign in with your old password and
check your apps. On a new VM, recreate the backup timer
from Install. Keep ~/dify.before-restore until
you're happy everything is back.
Troubleshooting
On the VM, in ~/dify/docker:
- 502 Bad Gateway right after a start: the API is still migrating and
booting; give it three minutes.
docker compose logs -f apishows progress, anddocker compose psshowsapihealthywhen it's ready. - Plugin install fails with
permission denied:sudo chown -R 1001:1001 volumes/plugin_daemon && docker compose restart plugin_daemon. - Model errors:
docker compose logs --tail=100 plugin_daemon. Check the provider's base URL ishttps://llm.int.exe.xyz/v1(OpenAI) orhttps://llm.int.exe.xyz(Anthropic), and that the model is inhttps://llm.int.exe.xyz/models.json. - Web app or API links point at the wrong address: the
*_URLlines in.envmust match your VM's name. Fix them, thendocker compose up -d. - The console won't stay signed in: open it at
https://<vm>.exe.xyz:8080/, the address inCONSOLE_WEB_URL. - HTTP Request or Code nodes fail with
403: Dify's SSRF proxy blocks private addresses other than*.int.exe.xyz.docker compose logs --tail=50 ssrf_proxy. - Disk full:
df -h /,docker system df, anddu -sh ~/dify-backups ~/dify/docker/volumes. - Everything else:
docker compose logs --tail=100 api worker web nginx.
Frequently asked questions#
How big a VM do I need?
Dify asks for 2 CPUs and 4 GB of memory, and the default VM has 2 CPUs and 8 GB; the stack idles at about 2 GB. The images take about 12 GB of disk, so make the VM with 40 GB to leave room for updates, documents, and backups. Grow it later with ssh exe.dev resize.
Do I need an OpenAI or Anthropic API key?
No. Dify's OpenAI and Anthropic plugins talk to exe.dev's LLM gateway, which needs no key, so a placeholder goes in the key field. Usage counts against your exe.dev LLM allocation. Other providers' plugins work too, with their own keys.
Who can see my console and my apps?
The console on port 8080 is reachable only by people you share the VM with, and they still need a Dify account. Published apps and the API on port 8000 are private too until you run share set-public; then anyone can open your web apps, and the API needs an app's key.
Can customers use my chatbot without an exe.dev account?
Yes, once port 8000 is public. It serves only web apps, the API, MCP, and webhooks, so making it public doesn't expose the console. See Go public.
Is this the same as Dify Cloud?
It's the same open-source Dify (the Community Edition), with one workspace. It has no hosted model credits, no billing, and no single sign-on; email invitations need SMTP, but Dify shows an invitation link you can send yourself.
Can I use Dify commercially?
Yes, including as the backend for your own products. The license adds two conditions to Apache 2.0: running Dify as a multi-tenant service needs a commercial license, and you may not remove Dify's logo or copyright from its web pages.
How much does it cost?
Dify's Community Edition is free. You pay for your exe.dev plan and the disk, and model calls count against your exe.dev LLM allocation.
Updated Nov 16, 2026 · tested end to end Nov 16, 2026 · Markdown · manifest.json · Something wrong? Tell us