fix: 代码审查修复 - .env.docker排除、nginx/ssrf配置文件、web端口、hybrid检索、示例文档
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
# ============================================================
|
||||
# Dify Docker 内部服务通信环境变量
|
||||
# 此文件由 docker-compose.yml 的 env_file 引用
|
||||
# 请勿提交到 Git,已在 .gitignore 中排除
|
||||
# ============================================================
|
||||
|
||||
# 内部服务间通信不需要修改以下值
|
||||
# DB/Redis 等地址使用 docker-compose 中的服务名
|
||||
|
||||
EDITION=SELF_HOSTED
|
||||
CONF_GIT_SYNC_ENABLED=false
|
||||
|
||||
# 知识库检索配置
|
||||
INDEXING_MAX_SEGMENTATION_TOKENS=500
|
||||
INDEXING_MAX_SEGMENTATION_CHUNKS_PER_FILE=10
|
||||
INDEXING_SEGMENTATION_SEPARATOR=['\n','\n\n',' ','。','!','?',';',';']
|
||||
|
||||
# 批量处理配置
|
||||
BATCH_PROCESSING_ENABLED=true
|
||||
|
||||
# 多模态配置
|
||||
MULTIMODAL_ENABLED=true
|
||||
|
||||
# 文件上传限制
|
||||
UPLOAD_FILE_SIZE_LIMIT=50
|
||||
UPLOAD_IMAGE_FILE_SIZE_LIMIT=20
|
||||
|
||||
# Celery 队列配置
|
||||
CELERY_QUEUES=dataset,generation,mail
|
||||
|
||||
# 文档解析配置
|
||||
DOCUMENT_PARSERS=pdf,txt,md,csv,xlsx,pptx,docx
|
||||
@@ -111,6 +111,9 @@ services:
|
||||
environment:
|
||||
- NEXT_PUBLIC_API_BASE_URL=${NEXT_PUBLIC_API_BASE_URL:-}
|
||||
- NEXT_PUBLIC_DEPLOY_ENV=${NEXT_PUBLIC_DEPLOY_ENV:-PRODUCTION}
|
||||
# 不使用 Nginx 时可直接访问 Web(设置 WEB_PORT=3000 启用)
|
||||
ports:
|
||||
- "${WEB_PORT:-}"
|
||||
volumes:
|
||||
- web_config:/app/config
|
||||
depends_on:
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
# Nginx 反向代理配置
|
||||
# 西安云美电子科技有限公司 - 企业知识库
|
||||
|
||||
upstream dify_api {
|
||||
server api:5001;
|
||||
}
|
||||
|
||||
upstream dify_web {
|
||||
server web:3000;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
# 请求体大小限制(文件上传)
|
||||
client_max_body_size 50M;
|
||||
|
||||
# API 请求
|
||||
location /console/api {
|
||||
proxy_pass http://dify_api;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# WebSocket 支持
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
|
||||
location /v1 {
|
||||
proxy_pass http://dify_api;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# SSE 支持
|
||||
proxy_buffering off;
|
||||
proxy_cache off;
|
||||
proxy_read_timeout 300s;
|
||||
}
|
||||
|
||||
# 静态资源
|
||||
location /files {
|
||||
proxy_pass http://dify_api;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
|
||||
location /elegant {
|
||||
proxy_pass http://dify_api;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
# Web 前端
|
||||
location / {
|
||||
proxy_pass http://dify_web;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
}
|
||||
|
||||
# HTTPS 配置(取消注释并配置 SSL 证书后启用)
|
||||
# server {
|
||||
# listen 443 ssl;
|
||||
# server_name kb.xayunmei.com;
|
||||
#
|
||||
# ssl_certificate /etc/nginx/ssl/server.crt;
|
||||
# ssl_certificate_key /etc/nginx/ssl/server.key;
|
||||
# ssl_protocols TLSv1.2 TLSv1.3;
|
||||
# ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
#
|
||||
# client_max_body_size 50M;
|
||||
#
|
||||
# # 同上 location 配置...
|
||||
# }
|
||||
|
||||
# HTTP → HTTPS 重定向(启用 HTTPS 后取消注释)
|
||||
# server {
|
||||
# listen 80;
|
||||
# server_name kb.xayunmei.com;
|
||||
# return 301 https://$server_name$request_uri;
|
||||
# }
|
||||
@@ -0,0 +1,38 @@
|
||||
# Squid SSRF Proxy 配置模板
|
||||
# 用于 Dify 的 HTTP 请求代理,防止 SSRF 攻击
|
||||
|
||||
# 端口
|
||||
http_port 3128
|
||||
|
||||
# 访问控制
|
||||
acl SSL_ports port 443
|
||||
acl Safe_ports port 80
|
||||
acl Safe_ports port 443
|
||||
acl Safe_ports port 1025-65535
|
||||
acl CONNECT method CONNECT
|
||||
|
||||
# 拒绝非安全端口
|
||||
http_access deny !Safe_ports
|
||||
http_access deny CONNECT !SSL_ports
|
||||
|
||||
# 允许 Dify 内部服务访问
|
||||
acl dify_services src 172.16.0.0/12 192.168.0.0/16 10.0.0.0/8
|
||||
http_access allow dify_services
|
||||
|
||||
# 拒绝其他所有访问
|
||||
http_access deny all
|
||||
|
||||
# 不显示 Squid 版本
|
||||
httpd_suppress_version_string on
|
||||
|
||||
# 日志格式
|
||||
access_log /var/log/squid/access.log squid
|
||||
cache_log /var/log/squid/cache.log
|
||||
|
||||
# 禁用缓存(仅作为代理使用)
|
||||
cache deny all
|
||||
|
||||
# 连接超时
|
||||
connect_timeout 30 seconds
|
||||
read_timeout 60 seconds
|
||||
request_timeout 60 seconds
|
||||
Reference in New Issue
Block a user