PassNAT LogoPassNAT

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

作者

小编

发布时间

Curving abstract shapes with an orange and blue gradient

项目介绍

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 service
4 api:
5 image: langgenius/dify-api:0.10.2
6 restart: always
7 environment:
8 # Startup mode, 'api' starts the API server.
9 MODE: api
10 # The log level for the application.
11 # Supported values are `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`
12 LOG_LEVEL: INFO
13 # A secret key that is used for securely signing the session cookie
14 # and encrypting sensitive information on the database.
15 # You can generate a strong key using `openssl rand -base64 42`.
16 SECRET_KEY: sk-9f73s3ljTXVcMT3Blb3ljTqtsKiGHXVcMT3BlbkFJLK7U
17 # The configurations of postgres database connection.
18 # It is consistent with the configuration in the 'db' service below.
19 DB_USERNAME: postgres
20 DB_PASSWORD: difyai123456
21 DB_HOST: db
22 DB_PORT: 5432
23 DB_DATABASE: dify
24 # The configurations of redis connection.
25 # It is consistent with the configuration in the 'redis' service below.
26 REDIS_HOST: redis
27 REDIS_PORT: 6379
28 REDIS_PASSWORD: difyai123456
29 REDIS_DB: 0
30 # The configurations of celery broker.
31 CELERY_BROKER_URL: redis://:difyai123456@redis:6379/1
32 # 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: local
36 STORAGE_LOCAL_PATH: storage
37 # The Vector database configurations, support: `weaviate`, `qdrant`, `milvus`, `relyt`.
38 VECTOR_STORE: weaviate
39 WEAVIATE_ENDPOINT: http://weaviate:8080
40 WEAVIATE_API_KEY: WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih
41 depends_on:
42 - db
43 - redis
44 volumes:
45 # Mount the storage directory to the container, for storing user files.
46 - ./volumes/app/storage:/app/storage
47 networks:
48 - dify
49
50 # worker service
51 # The Celery worker for processing the queue.
52 worker:
53 image: langgenius/dify-api:0.10.2
54 restart: always
55 environment:
56 # Startup mode, 'worker' starts the Celery worker for processing the queue.
57 MODE: worker
58 # --- All the configurations below are the same as those in the 'api' service. ---
59 LOG_LEVEL: INFO
60 SECRET_KEY: sk-9f73s3ljTXVcMT3Blb3ljTqtsKiGHXVcMT3BlbkFJLK7U
61 DB_USERNAME: postgres
62 DB_PASSWORD: difyai123456
63 DB_HOST: db
64 DB_PORT: 5432
65 DB_DATABASE: dify
66 REDIS_HOST: redis
67 REDIS_PORT: 6379
68 REDIS_PASSWORD: difyai123456
69 REDIS_DB: 0
70 CELERY_BROKER_URL: redis://:difyai123456@redis:6379/1
71 STORAGE_TYPE: local
72 STORAGE_LOCAL_PATH: storage
73 VECTOR_STORE: weaviate
74 WEAVIATE_ENDPOINT: http://weaviate:8080
75 WEAVIATE_API_KEY: WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih
76 depends_on:
77 - db
78 - redis
79 volumes:
80 - ./volumes/app/storage:/app/storage
81 networks:
82 - dify
83
84 # Frontend web application.
85 web:
86 image: langgenius/dify-web:0.10.2
87 restart: always
88 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 is
92 # different from api or web app domain.
93 # example: http://cloud.dify.ai/console/api
94 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 from
96 # console or api domain.
97 # example: http://udify.app/api
98 APP_API_URL: ''
99 depends_on:
100 - api
101 networks:
102 - dify
103
104 # The postgres database.
105 db:
106 image: postgres:15-alpine
107 restart: always
108 environment:
109 PGUSER: postgres
110 # The password for the default postgres user.
111 POSTGRES_PASSWORD: difyai123456
112 # The name of the default postgres database.
113 POSTGRES_DB: dify
114 # postgres data directory
115 PGDATA: /var/lib/postgresql/data/pgdata
116 volumes:
117 - ./volumes/db/data:/var/lib/postgresql/data
118 networks:
119 - dify
120 healthcheck:
121 test: ['CMD', 'pg_isready']
122 interval: 1s
123 timeout: 3s
124 retries: 30
125
126 # The redis cache.
127 redis:
128 image: redis:6-alpine
129 restart: always
130 volumes:
131 # Mount the redis data directory to the container.
132 - ./volumes/redis/data:/data
133 # Set the redis password when startup redis server.
134 command: redis-server --requirepass difyai123456
135 networks:
136 - dify
137 healthcheck:
138 test: ['CMD', 'redis-cli', 'ping']
139
140 # The DifySandbox
141 sandbox:
142 image: langgenius/dify-sandbox:0.2.10
143 restart: always
144 environment:
145 # The DifySandbox configurations
146 # 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-sandbox
149 GIN_MODE: 'release'
150 WORKER_TIMEOUT: 15
151 volumes:
152 - ./volumes/sandbox/dependencies:/dependencies
153 networks:
154 - dify
155 healthcheck:
156 test: ['CMD', 'curl', '-f', 'http://localhost:8194/health']
157
158 # Weaviate vector database.
159 weaviate:
160 image: semitechnologies/weaviate:1.19.0
161 restart: always
162 volumes:
163 # Mount the Weaviate data directory to the container.
164 - ./volumes/weaviate:/var/lib/weaviate
165 environment:
166 # The Weaviate configurations
167 # You can refer to the [Weaviate](https://weaviate.io/developers/weaviate/config-refs/env-vars) documentation for more information.
168 QUERY_DEFAULTS_LIMIT: 25
169 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 - dify
180 healthcheck:
181 test: ['CMD', 'curl', '-f', 'http://localhost:8080/v1/.well-known/ready']
182
183 # The nginx reverse proxy.
184 # used for reverse proxying the API service and Web service.
185 nginx:
186 image: nginx:latest
187 restart: always
188 volumes:
189 - ./nginx/nginx.conf:/etc/nginx/nginx.conf
190 depends_on:
191 - api
192 - web
193 ports:
194 - "80:80"
195 networks:
196 - dify
197
198networks:
199 dify:
200 driver: bridge

打开飞牛 NAS 或其他的 NAS 设备

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

点击 Compose -> 新建项目

这里需要改成你需要的账号和密码,其他的保持不变。

如果提示端口被占用可以修改下面的字段,但是需要保持格式正确。

穿透公网

打开帕斯内网穿透控制台,点击隧道管理-隧道列表

点击创建新隧道

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

接下来填写信息,隧道名称可以随便填写

本地 IP 默认就可以

传输协议可以选择 TCP 也可以选择 HTTP/HTTPS

HTTP 就是域名的形式,教程以使用 TCP 为演示

本项目中如果没有修改端口的话默认是 80 端口,这里本地 IP 就填 80

远程端口可以留空也可以自定义。下图仅做参考,请按照实际项目端口添加。

填写完毕点击确定

点击刚才创建好的隧道,点击获取配置文件

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

打开后粘贴刚才复制的配置文件,点击确定即可

复制帕斯内网穿透控制台的访问 IP 和端口

可以看到已经正常穿透成功了

本篇教程结束