Dify Ai社区版几个常见配置,更新中。

https://www.ffeeii.com/ffeeii.com/2025/03/dify.ai.jpg

Dify的社区版本在服务器安装后,需要进行几个常见配置进行优化

.env 的目录在 dify/docker/.env

#关闭服务
docker compose down
#启动服务
docker compose up -d
#重启服务
docker compose restart

开启SSL

安装如下参数进行调整

  • NGINX_HTTPS_ENABLED=true
  • 配置 NGINX_SERVER_NAME
  • 配置 NGINX_SSL_CERT_FILENAME
  • 证书位置NGINX_SSL_CERT_FILENAME、NGINX_SSL_CERT_KEY_FILENAME
NGINX_SERVER_NAME=xxx
NGINX_HTTPS_ENABLED=true
# HTTP port
NGINX_PORT=80
# SSL settings are only applied when HTTPS_ENABLED is true
NGINX_SSL_PORT=443
# if HTTPS_ENABLED is true, you're required to add your own SSL certificates/keys to the `./nginx/ssl` directory
# and modify the env vars below accordingly.
NGINX_SSL_CERT_FILENAME=xxx
NGINX_SSL_CERT_KEY_FILENAME=xxx
NGINX_SSL_PROTOCOLS=TLSv1.1 TLSv1.2 TLSv1.3

邮件

# Mail type, support: resend, smtp
MAIL_TYPE=smtp

# Default send from email address, if not specified
MAIL_DEFAULT_SEND_FROM=

# API-Key for the Resend email provider, used when MAIL_TYPE is `resend`.
RESEND_API_URL=https://api.resend.com
RESEND_API_KEY=your-resend-api-key


# SMTP server configuration, used when MAIL_TYPE is `smtp`
SMTP_SERVER=xxx
SMTP_PORT=465
SMTP_USERNAME=xxx
SMTP_PASSWORD=xxx
SMTP_USE_TLS=true
SMTP_OPPORTUNISTIC_TLS=false

应用内的插件提速

好多同学反馈说安装插件太慢,配置PIP_MIRROR_URL,一般是最后一行,PIP_MIRROR_URL 前面有个注释,值复制下来就可以

vi dify/docker/.env
PIP_MIRROR_URL=https://pypi.tuna.tsinghua.edu.cn/simple

云存储OSS

从本地存储目录中的 ‘upload_files’ 和 ‘privkeys’ 文件夹迁移数据到OSS

设置 STORAGE_TYPE=aliyun-oss

ALIYUN_OSS_BUCKET_NAME=your-bucket-name
ALIYUN_OSS_ACCESS_KEY=your-access-key
ALIYUN_OSS_SECRET_KEY=your-secret-key
ALIYUN_OSS_ENDPOINT=https://oss-ap-southeast-1-internal.aliyuncs.com
ALIYUN_OSS_REGION=ap-southeast-1
ALIYUN_OSS_AUTH_VERSION=v4
# Don't start with '/'. OSS doesn't support leading slash in object names.
ALIYUN_OSS_PATH=your-path