开源AI开发平台Dify本地部署教程,配置帕斯内网穿透实现远程访问智能体工作流
作者
小编
发布时间

项目介绍
Dify 是一个开源的 LLM 应用开发平台,提供直观的界面来构建 AI 工作流、RAG 管道、智能体功能、模型管理和可观测性功能等。它让你能够快速从原型转向生产环境。
Dify 支持数百种专有/开源 LLM 模型的无缝集成,包括 GPT、Mistral、Llama3 等,以及任何 OpenAI API 兼容的模型。平台提供可视化画布来构建和测试强大的 AI 工作流,内置 50+ 工具供 AI 智能体使用,如 Google 搜索、DALL·E、Stable Diffusion 等。
该平台具有完整的 RAG 能力,支持从文档摄取到检索的全流程,开箱即用地支持从 PDF、PPT 等常见文档格式中提取文本。同时提供 LLMOps 功能,可以监控和分析应用日志及性能,基于生产数据持续改进提示词、数据集和模型。
项目地址: 点我跳转
部署安装
如需在外也打开项目需要配置内网穿透使用,点击前往 帕斯内网穿透,先注册好账号备用。
复制下列的配置文件
1version: '3'2services:3 # API service4 api:5 image: langgenius/dify-api:0.10.26 restart: always7 environment:8 # Startup mode, 'api' starts the API server.9 MODE: api10 # The log level for the application.11 # Supported values are `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`12 LOG_LEVEL: INFO13 # A secret key that is used for securely signing the session cookie14 # and encrypting sensitive information on the database.15 # You can generate a strong key using `openssl rand -base64 42`.16 SECRET_KEY: sk-9f73s3ljTXVcMT3Blb3ljTqtsKiGHXVcMT3BlbkFJLK7U17 # The configurations of postgres database connection.18 # It is consistent with the configuration in the 'db' service below.19 DB_USERNAME: postgres20 DB_PASSWORD: difyai12345621 DB_HOST: db22 DB_PORT: 543223 DB_DATABASE: dify24 # The configurations of redis connection.25 # It is consistent with the configuration in the 'redis' service below.26 REDIS_HOST: redis27 REDIS_PORT: 637928 REDIS_PASSWORD: difyai12345629 REDIS_DB: 030 # The configurations of celery broker.31 CELERY_BROKER_URL: redis://:difyai123456@redis:6379/132 # The type of storage to use for storing user files.33 # The default is `local`, which stores files locally.34 # If you want to store files in S3, set this to `s3` and configure the S3 environment variables below.35 STORAGE_TYPE: local36 STORAGE_LOCAL_PATH: storage37 # The Vector database configurations, support: `weaviate`, `qdrant`, `milvus`, `relyt`.38 VECTOR_STORE: weaviate39 WEAVIATE_ENDPOINT: http://weaviate:808040 WEAVIATE_API_KEY: WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih41 depends_on:42 - db43 - redis44 volumes:45 # Mount the storage directory to the container, for storing user files.46 - ./volumes/app/storage:/app/storage47 networks:48 - dify4950 # worker service51 # The Celery worker for processing the queue.52 worker:53 image: langgenius/dify-api:0.10.254 restart: always55 environment:56 # Startup mode, 'worker' starts the Celery worker for processing the queue.57 MODE: worker58 # --- All the configurations below are the same as those in the 'api' service. ---59 LOG_LEVEL: INFO60 SECRET_KEY: sk-9f73s3ljTXVcMT3Blb3ljTqtsKiGHXVcMT3BlbkFJLK7U61 DB_USERNAME: postgres62 DB_PASSWORD: difyai12345663 DB_HOST: db64 DB_PORT: 543265 DB_DATABASE: dify66 REDIS_HOST: redis67 REDIS_PORT: 637968 REDIS_PASSWORD: difyai12345669 REDIS_DB: 070 CELERY_BROKER_URL: redis://:difyai123456@redis:6379/171 STORAGE_TYPE: local72 STORAGE_LOCAL_PATH: storage73 VECTOR_STORE: weaviate74 WEAVIATE_ENDPOINT: http://weaviate:808075 WEAVIATE_API_KEY: WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih76 depends_on:77 - db78 - redis79 volumes:80 - ./volumes/app/storage:/app/storage81 networks:82 - dify8384 # Frontend web application.85 web:86 image: langgenius/dify-web:0.10.287 restart: always88 environment:89 CONSOLE_API_URL: ''90 APP_API_URL: ''91 # The base URL of console application api server, refers to the Console base URL of WEB service if console domain is92 # different from api or web app domain.93 # example: http://cloud.dify.ai/console/api94 CONSOLE_API_URL: ''95 # The URL for Web APP api server, refers to the Web App base URL of WEB service if web app domain is different from96 # console or api domain.97 # example: http://udify.app/api98 APP_API_URL: ''99 depends_on:100 - api101 networks:102 - dify103104 # The postgres database.105 db:106 image: postgres:15-alpine107 restart: always108 environment:109 PGUSER: postgres110 # The password for the default postgres user.111 POSTGRES_PASSWORD: difyai123456112 # The name of the default postgres database.113 POSTGRES_DB: dify114 # postgres data directory115 PGDATA: /var/lib/postgresql/data/pgdata116 volumes:117 - ./volumes/db/data:/var/lib/postgresql/data118 networks:119 - dify120 healthcheck:121 test: ['CMD', 'pg_isready']122 interval: 1s123 timeout: 3s124 retries: 30125126 # The redis cache.127 redis:128 image: redis:6-alpine129 restart: always130 volumes:131 # Mount the redis data directory to the container.132 - ./volumes/redis/data:/data133 # Set the redis password when startup redis server.134 command: redis-server --requirepass difyai123456135 networks:136 - dify137 healthcheck:138 test: ['CMD', 'redis-cli', 'ping']139140 # The DifySandbox141 sandbox:142 image: langgenius/dify-sandbox:0.2.10143 restart: always144 environment:145 # The DifySandbox configurations146 # Make sure you are changing this key for your deployment with a strong key.147 # You can generate a strong key using `openssl rand -base64 42`.148 API_KEY: dify-sandbox149 GIN_MODE: 'release'150 WORKER_TIMEOUT: 15151 volumes:152 - ./volumes/sandbox/dependencies:/dependencies153 networks:154 - dify155 healthcheck:156 test: ['CMD', 'curl', '-f', 'http://localhost:8194/health']157158 # Weaviate vector database.159 weaviate:160 image: semitechnologies/weaviate:1.19.0161 restart: always162 volumes:163 # Mount the Weaviate data directory to the container.164 - ./volumes/weaviate:/var/lib/weaviate165 environment:166 # The Weaviate configurations167 # You can refer to the [Weaviate](https://weaviate.io/developers/weaviate/config-refs/env-vars) documentation for more information.168 QUERY_DEFAULTS_LIMIT: 25169 AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'false'170 PERSISTENCE_DATA_PATH: '/var/lib/weaviate'171 DEFAULT_VECTORIZER_MODULE: 'none'172 CLUSTER_HOSTNAME: 'node1'173 AUTHENTICATION_APIKEY_ENABLED: 'true'174 AUTHENTICATION_APIKEY_ALLOWED_KEYS: 'WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih'175 AUTHENTICATION_APIKEY_USERS: 'hello@dify.ai'176 AUTHORIZATION_ADMINLIST_ENABLED: 'true'177 AUTHORIZATION_ADMINLIST_USERS: 'hello@dify.ai'178 networks:179 - dify180 healthcheck:181 test: ['CMD', 'curl', '-f', 'http://localhost:8080/v1/.well-known/ready']182183 # The nginx reverse proxy.184 # used for reverse proxying the API service and Web service.185 nginx:186 image: nginx:latest187 restart: always188 volumes:189 - ./nginx/nginx.conf:/etc/nginx/nginx.conf190 depends_on:191 - api192 - web193 ports:194 - "80:80"195 networks:196 - dify197198networks:199 dify:200 driver: bridge
打开飞牛 NAS 或其他的 NAS 设备

项目名称可以随便填,点击创建 docker-compose.yml

点击 Compose -> 新建项目
这里需要改成你需要的账号和密码,其他的保持不变。
如果提示端口被占用可以修改下面的字段,但是需要保持格式正确。
穿透公网
打开帕斯内网穿透控制台,点击隧道管理-隧道列表

点击创建新隧道
隧道节点可以随便选,一般选个负载低的就可以

接下来填写信息,隧道名称可以随便填写
本地 IP 默认就可以
传输协议可以选择 TCP 也可以选择 HTTP/HTTPS
HTTP 就是域名的形式,教程以使用 TCP 为演示
本项目中如果没有修改端口的话默认是 80 端口,这里本地 IP 就填 80
远程端口可以留空也可以自定义。下图仅做参考,请按照实际项目端口添加。

填写完毕点击确定
点击刚才创建好的隧道,点击获取配置文件

回到飞牛 NAS,点击应用中心下载 frpc 客户端

打开后粘贴刚才复制的配置文件,点击确定即可
复制帕斯内网穿透控制台的访问 IP 和端口
可以看到已经正常穿透成功了
本篇教程结束