OpenWebUI AI聊天

docker代理

  • vi /etc/docker/daemon.json

    {
      "proxies": {
        "https-proxy": "http://192.168.1.120:7890",
        "no-proxy": "huecker.io,ghcr.io,*.test.example.com,.example.org,127.0.0.0/8"
      }
    }
  • sudo systemctl restart docker
  • 也可以手动拉镜像 docker pull ghcr.io/open-webui/open-webui:main

国外服务器打包镜像

[ghost@instance-20260324-0911 ~]$ docker pull ghcr.io/open-webui/open-webui:0.8.10
0.8.10: Pulling from open-webui/open-webui
43be232c7f18: Pull complete
...
7549994be85a: Pull complete
d9b598766922: Download complete
0c7ee400de66: Download complete
Digest: sha256:ee057955040ce91e3e787e4b7978c9c23e828972c68d01d787ed40f9a307df9f
Status: Downloaded newer image for ghcr.io/open-webui/open-webui:0.8.10
ghcr.io/open-webui/open-webui:0.8.10
[ghost@instance-20260324-0911 ~]$ docker images
                                                                                                                                                                                    
IMAGE                                  ID             DISK USAGE   CONTENT SIZE   EXTRA

ghcr.io/open-webui/open-webui:0.8.10   ee057955040c       5.94GB         1.54GB

[ghost@instance-20260324-0911 ~]$ docker save -o open-webui-0.8.10.tar ghcr.io/open-webui/open-webui:0.8.10
[ghost@instance-20260324-0911 ~]$ ll


-rw------- 1 ghost ghost 1541165568 Mar 25 11:28 open-webui-0.8.10.tar

拷贝到目标服务器 docker load -i xxx

docker-compose.yml

services:
  open-webui:
    image: ghcr.io/open-webui/open-webui:0.8.10  # github源根本拉不动
    # image: dyrnq/open-webui:0.3.22  # docker hub的源
    container_name: open-webui
    environment:
      # 1. 基础环境设置
      - 'ENABLE_OLLAMA_API=False'
      - 'USE_OLLAMA_DOCKER=False'
      - 'TZ=Asia/Shanghai'
      - 'WEBUI_AUTH=True'  # 建议开启登录认证
      
      # 2. 配置 LM Studio 的 OpenAI 兼容接口
      - 'OPENAI_API_BASE_URL=http://192.168.1.120:1234/v1'
      - 'OPENAI_API_KEY=sk-lm-G69sckC7:wGdZ280sephh2m6aV0uT'
      
      # 3. 这里的 Key 建议填入一个随机字符串,用于加密 session
      - 'WEBUI_SECRET_KEY=kaicong'
      
      # RAG 文档检索功能 无法连接到 huggingface.co
      - 'HF_ENDPOINT=https://hf-mirror.com'
      - 'HF_HUB_OFFLINE=0'
      - 'OFFLINE_MODE=True'

    volumes:
      - ./data/open-webui:/app/backend/data
    networks:
      - ghost_net
    restart: unless-stopped

networks:
  ghost_net:
    external: true  # 声明使用已存在的外部网络

conf.d/open-webui.conf

server {
    listen 80;
    server_name kc.com chat.kc.com www.kc.com;

    # 增加上传文件大小限制(用于上传文档进行 RAG 解析)
    client_max_body_size 100M;

    location / {
        # 使用 Docker 容器名和内部端口 8080
        proxy_pass http://open-webui:8080;
        
        # 标准代理头设置
        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";
        
        # --- 修正后的指令:指令与参数之间使用空格 ---
        proxy_cache off;      # 修正:去掉了下划线
        proxy_buffering off;  # 修正:去掉了下划线
        proxy_read_timeout 300s; # 防止长文本生成时连接超时
    }
}