当前位置: 首页 > news >正文

dify部署及SSL自签实现

背景

项目A开发同学需要部署一套dify来测试某些功能

使用docker compose方式部署
从github中clone仓库,推到私有gitlab
下载其中的镜像到云上私仓
替换镜像
启动

部署

docker配置 略

# clone dify仓库
git clone --single-branch https://github.com/langgenius/dify.git
cd dify
git remote -v
git remote remove origin
# 配置远程仓库为私有镜像仓库 后期做一些二次开发
git remote add origing xxxx

取出镜像

(base) root@dev:/tmp/dify# grep -i image ./docker/docker-compose.yaml UPLOAD_IMAGE_FILE_SIZE_LIMIT: ${UPLOAD_IMAGE_FILE_SIZE_LIMIT:-10}image: langgenius/dify-api:1.9.2image: langgenius/dify-api:1.9.2image: langgenius/dify-api:1.9.2image: langgenius/dify-web:1.9.2image: postgres:15-alpineimage: redis:6-alpineimage: langgenius/dify-sandbox:0.2.12image: langgenius/dify-plugin-daemon:0.3.3-localimage: ubuntu/squid:latestimage: certbot/certbotimage: nginx:latestimage: semitechnologies/weaviate:1.27.0image: langgenius/qdrant:v1.7.3image: pgvector/pgvector:pg16# get image from https://www.vastdata.com.cn/image: vastdata/vastbase-vectorimage: tensorchord/pgvecto-rs:pg16-v0.3.0image: ghcr.io/chroma-core/chroma:0.5.20image: oceanbase/oceanbase-ce:4.3.5-ltsimage: container-registry.oracle.com/database/free:latestimage: quay.io/coreos/etcd:v3.5.5image: minio/minio:RELEASE.2023-03-20T20-16-18Zimage: milvusdb/milvus:v2.5.15image: opensearchproject/opensearch:latestimage: opensearchproject/opensearch-dashboards:latestimage: opengauss/opengauss:7.0.0-RC1image: myscale/myscaledb:1.6.4image: matrixorigin/matrixone:2.1.1image: docker.elastic.co/elasticsearch/elasticsearch:8.14.3image: docker.elastic.co/kibana/kibana:8.14.3image: downloads.unstructured.io/unstructured-io/unstructured-api:latest

将这些镜像转入私仓

for i in `grep image: ./docker/docker-compose.yaml | awk -F ': ' '{print $2}'`;do docker pull $i && docker tag $i xxx/dify/$i; docker push xxx/dify/$i ;done
#!/bin/bash# Define your repository URL
REPO_URL="x.com/xx/dify"# Process the docker-compose.yaml to get the image names
grep image: docker-compose.yaml | uniq -c | awk -F ': ' '{print $2}' | while read image; do# Extract the image name after the last '/' (if any)image_name=$(echo $image | awk -F'/' '{print $NF}')# Tag the image with the desired repository and tag formatdocker tag $image $REPO_URL/$image_namedocker push $image $REPO_URL/$image_name
done
cd dify/docker/
cp .env.example .env
docker compose up
docker compose ps

.env中需要配置的变量

FILES_URL=http://xxxx.com
INTERNAL_FILES_URL=http://api:5001
# ------------------------------
# Environment Variables for Nginx reverse proxy
# ------------------------------
NGINX_SERVER_NAME=xxx
NGINX_HTTPS_ENABLED=false
# 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=_x
NGINX_SSL_CERT_KEY_FILENAME=_.x
NGINX_SSL_PROTOCOLS=TLSv1.1 TLSv1.2 TLSv1.3# Nginx performance tuning
NGINX_WORKER_PROCESSES=auto
NGINX_CLIENT_MAX_BODY_SIZE=100M
NGINX_KEEPALIVE_TIMEOUT=65# Proxy settings
NGINX_PROXY_READ_TIMEOUT=3600s
NGINX_PROXY_SEND_TIMEOUT=3600s# Set true to accept requests for /.well-known/acme-challenge/
NGINX_ENABLE_CERTBOT_CHALLENGE=false# ------------------------------
# Certbot Configuration
# ------------------------------# Email address (required to get certificates from Let's Encrypt)
CERTBOT_EMAIL=your_email@example.com# Domain name
CERTBOT_DOMAIN=your_domain.com# certbot command options
# i.e: --force-renewal --dry-run --test-cert --debug
CERTBOT_OPTIONS=

certbot实现SSL自签名

  1. 使用http方式将nginx运行;允许访问.well-known/acme-challenge/
vim .env
NGINX_ENABLE_CERTBOT_CHALLENGE=true
  1. 使用certbot容器来申请ssl证书
# ------------------------------
# Environment Variables for Nginx reverse proxy
# ------------------------------
NGINX_SERVER_NAME=aa.bb.com
NGINX_HTTPS_ENABLED=false
# 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=dify.crt
NGINX_SSL_CERT_KEY_FILENAME=dify.key
NGINX_SSL_PROTOCOLS=TLSv1.1 TLSv1.2 TLSv1.3# Nginx performance tuning
NGINX_WORKER_PROCESSES=auto
NGINX_CLIENT_MAX_BODY_SIZE=100M
NGINX_KEEPALIVE_TIMEOUT=65# Proxy settings
NGINX_PROXY_READ_TIMEOUT=3600s
NGINX_PROXY_SEND_TIMEOUT=3600s# Set true to accept requests for /.well-known/acme-challenge/
NGINX_ENABLE_CERTBOT_CHALLENGE=true# ------------------------------
# Certbot Configuration
# ------------------------------# Email address (required to get certificates from Let's Encrypt)
CERTBOT_EMAIL=your123@qq.com# Domain name
CERTBOT_DOMAIN=aa.bb.com# certbot command options
# i.e: --force-renewal --dry-run --test-cert --debug
CERTBOT_OPTIONS=--force-renewal
  1. 复制SSL证书到nginx指定路径下
# nginx证书存放路径
/data/dify/docker/nginx/ssl
  1. 配置.env变量文件
NGINX_HTTPS_ENABLED=true
  1. 重启nginx加载证书及域名
# 进入nginx容器中
nginx -s reload
# docker compose重启
docker-compose restart nginx
# 删除容器重新创建

references
官方中文文档
https://docs.dify.ai/zh-hans/introduction
github源码仓库
https://github.com/langgenius/dify

http://www.dtcms.com/a/520292.html

相关文章:

  • 云南省建设厅标准员网站手机兼职赚钱
  • Redis哈希表渐进式rehash深度解析:为何百万数据迁移不阻塞服务?
  • 广东省省考备考(第一百三十一天10.23)——科学推理:电学(第六节课)
  • Spring的三级缓存和SpringMVC的流程
  • 为什么麒麟信创系统需要开启overcommit_memory才能安装postgresql成功
  • PostGresql All语法
  • [java] 图文示八股
  • 【图像处理】图像形态学操作
  • 网站上传 空间 数据库开发一个电商平台app要多少钱
  • 如何制作网站链接数字镭网站开发
  • 使用python的matplotlib进行绘图
  • Nginx使用auth_request模块做外部认证集成Kibana
  • 【题解】洛谷 P2218 [HAOI2007] 覆盖问题 [二分 + 思维]
  • xss-labs pass-12
  • 企业网站建设服务电话做网站什么主题好做
  • 注册电气工程师(供配电)执业资格考试专业考试规范及设计手册(2025版)
  • 关于zwg技术的深度解析与应用前景
  • linux 什么做网站好网站优化课程培训
  • 键盘PCB为何对板厂要求更高?差异、难点及猎板解决方案解析
  • OMSDK WebView Display 接入步骤
  • 零基础新手小白快速了解掌握服务集群与自动化运维(十S四)储存服务-NFS文件储存
  • tidex-数字货币交易所
  • C#使用OpenVinoSharp+魔塔社区的读光中英文OCR ONNX模型进行文字检测(仅检测不做识别)
  • 积分商城小程序深圳seo网络优化公司
  • [Linux文件系统——Lesson17.软硬链接]
  • apr库在x86架构下交叉编译成arm64架构
  • 软件设计师-结构化分析方法-耦合
  • 响应式企业网站 下载网站制作是不是要先用ps做
  • 购买网站建设需要注意app软件开发制作公司电话
  • 【AI Agent】入门、学习、求职