本地部署dify出现Internal Server Error 解决方案
dify 版本:1.5.1
该解决方案适用于docker 使用代理而不是镜像站链接的情况。
今天本地部署dify时一打开一直弹Internal Server Error
尝试了网上的解决办法和issue中的所有解决办法后发现还是没有解决,问题一直出在api容器和plugin_daemon容器之间无法通信,查看日志会看到:
requests.exceptions.HTTPError: 502 Server Error: Bad Gateway for url: http://plugin_daemon:5002/plugin/330ba873-888a-4690-9122-d8b195abbd13/management/list?page=1&page_size=100
实际到api的容器内部使用curl -v http://plugin_daemon:5002/
检测连通性,发现
Uses proxy env variable no_proxy == 'kubernetes.docker.internal,127.0.0.0/8,localhost'
* Uses proxy env variable http_proxy == 'http://host.docker.internal:7897'
* Trying 192.168.65.254:7897...
* Connected to host.docker.internal (192.168.65.254) port 7897 (#0)
> GET http://plugin_daemon:5002/ HTTP/1.1
> Host: plugin_daemon:5002
> User-Agent: curl/7.88.1
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 502 Bad Gateway
< Connection: keep-alive
< Keep-Alive: timeout=4
< Proxy-Connection: keep-alive
< Content-Length: 0****
问题就出在这了,容器间内部通信走了我的代理网络,外部网络根本就识别不了这个地址,所以连接失败,解决办法也很简单,修改 docker-compose.yml 文件,为 api 和 worker 服务禁用或取消代理设置。
services:
# API service
api:
image: langgenius/dify-api:1.5.1
restart: always
environment:
# Use the shared environment variables.
<<: *shared-api-worker-env
#
# --- 添加下面这两行来禁用代理 ---
http_proxy: ""
https_proxy: ""
# ---------------------------------
#
# Startup mode, 'api' starts the API server.
MODE: api
# ... 其他配置 ...
# worker service
# The Celery worker for processing the queue.
worker:
image: langgenius/dify-api:1.5.1
restart: always
environment:
# Use the shared environment variables.
<<: *shared-api-worker-env
#
# --- 同样在这里添加这两行 ---
http_proxy: ""
https_proxy: ""
# ---------------------------
#
# Startup mode, 'worker' starts the Celery worker for processing the queue.
MODE: worker
# ... 其他配置 ...
修改完这两处,删除容器后重新docker compose down
然后再docker compose
启动后发现就没用这个问题了