> 技术文档 > Dify报错502 Bad gateway解决方案_dify 502 bad gateway

Dify报错502 Bad gateway解决方案_dify 502 bad gateway


找到docker-api-1的ip地址

注意:如果有多个ip,选择其中任意一个即可。

docker inspect --format \'{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}\' docker-api-1
196.128.0.8196.128.0.4

找到docker-web-1的ip地址

注意:如果有多个ip,选择其中任意一个。

docker inspect --format \'{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}\' docker-web-1
196.128.0.6

修改nginx配置文件

vim ${DIFY_HOME}/docker/nginx/conf.d/default.confvim ${DIFY_HOME}/docker/nginx/conf.d/default.conf.template

将default.conf和default.conf.template中的http://api:5001替换为http://196.128.0.8:5001,将http://web:3000替换为http://196.128.0.6:3000。

server { listen 80; server_name _; location /console/api { proxy_pass http://api:5001; # 改为proxy_pass http://196.128.0.8:5001; include proxy.conf; } location /api { proxy_pass http://api:5001; # 改为proxy_pass http://196.128.0.8:5001; include proxy.conf; } location /v1 { proxy_pass http://api:5001; # 改为proxy_pass http://196.128.0.8:5001; include proxy.conf; } location /files { proxy_pass http://api:5001; # 改为proxy_pass http://196.128.0.8:5001; include proxy.conf; } location / { proxy_pass http://web:3000; # 改为proxy_pass http://196.128.0.6:5001; include proxy.conf; } # placeholder for acme challenge location # placeholder for https config defined in https.conf.template }

修改.env文件

vim ${DIFY_HOME}/docker/.env

确认EXPOSE_NGINX_PORT=80,与${DIFY_HOME}/docker/nginx/conf.d/default.conf中listen指定的端口一致。
Dify报错502 Bad gateway解决方案_dify 502 bad gateway
Dify报错502 Bad gateway解决方案_dify 502 bad gateway

加载nginx配置

# 进入容器docker exec -it docker-nginx-1 bash# 加载配置sbin/nginx -s reload

Dify报错502 Bad gateway解决方案_dify 502 bad gateway