> 技术文档 > open-webui使用Searxng联网搜索_openwebui联网搜索

open-webui使用Searxng联网搜索_openwebui联网搜索


文章目录

  • Open WebUI结合代理过的Searxng实现联网搜索
    • 本地环境
    • 安装Open WebUI
    • 安装Searxng
    • 其它Web-Search
    • 参考文章

Open WebUI结合代理过的Searxng实现联网搜索

本身SearxngSearXNG | Open WebUI是一款多搜索引擎合在一起的浏览器,整体使用下来比google_pseGoogle PSE | Open WebUI引擎好用

特别注意:

  1. 使用Searxng需要对运行Searxng的容器设置代理,理论上无需对Open WebUI的容器设置主机网络代理,但在实际过程中,有观察到日志个别网站连接超时,且会不时请求下github版本,因此我都加了主机代理
  2. 使用google_pse则是由Open WebUI容器进行访问,需要设置主机代理
  3. 我的本机有http://127.0.0.1:7890的代理,后续有使用

本地环境

系统环境以及软件环境如下

centos 7.6open-webui v0.5.16docker 20.10.5

安装Open WebUI

Open WebUI安装过于简单,根据自己情况参考文档安装

⏱️ Quick Start | Open WebUI

这是我的docker-compose.yaml供参考

version: \'3.8\'services: open-webui: image: ghcr.io/open-webui/open-webui:latest container_name: open-webui restart: always ports: - \"3000:8080\" environment: # TZ: Asia/Shanghai OPENAI_API_KEY: \"your_secret_key\" #填不填无所谓 http_proxy: \"http://host.docker.internal:7890\" # 关键变量 https_proxy: \"http://host.docker.internal:7890\" no_proxy: \"localhost,127.0.0.1,.internal\" # 排除内网地址 extra_hosts: - \"host.docker.internal:172.17.0.1\" # 宿主网关IP解析 volumes: - /home/open-webui/data:/app/backend/data # /home/open-webui/data 为data映射路径,改为自己的 networks: - proxy-net # 专用网络 watchtower: image: containrrr/watchtower volumes: - /var/run/docker.sock:/var/run/docker.sock command: - --interval=300 - --debug # 添加调试模式 - open-webui environment: # TZ: Asia/Shanghai http_proxy: \"http://host.docker.internal:7890\" # 新增代理配置 https_proxy: \"http://host.docker.internal:7890\" no_proxy: \"localhost,127.0.0.1,.internal\" # 排除内网地址 extra_hosts: # 确保host解析 - \"host.docker.internal:172.17.0.1\" depends_on: - open-webuinetworks: proxy-net: driver: bridge

注: 这里安装了watchtower进行监控自动更新Open WebUI,由于使用的ghcr.io/open-webui/open-webui:latest镜像,因此也需要设置代理否则会连接超时导致更新失败

watchtower使用参考:🔄 Updating Open WebUI | Open WebUI

安装Searxng

  1. 拉取代码

    git clone https://github.com/searxng/searxng-docker.git
  2. 进入仓库

    cd searxng-docker
  3. 修改docker-compose.yaml,为下面内容

    version: \"3.7\"services: searxng: container_name: searxng image: docker.io/searxng/searxng:latest restart: unless-stopped networks: - searxng ports: - \"3001:8080\" #3001修改为自己想要的端口,8080不可修改 volumes: - ./searxng:/etc/searxng:rw environment: - SEARXNG_BASE_URL=http://192.168.0.231:3001 #本机IP:端口,例如192.168.0.231:3001,3001和上面对应一致,后面要用 - http_proxy=http://172.17.0.1:7890 # 修改为Docker网关IP - https_proxy=http://172.17.0.1:7890 cap_drop: - ALL cap_add: - CHOWN - SETGID - SETUID logging: driver: \"json-file\" options: max-size: \"1m\" max-file: \"1\"networks: searxng: driver: bridge
    1. 俩个3001端口要一致
    2. 使用的是本机的IPv4地址,或者是服务器公网IP
    3. http_proxy=http://172.17.0.1:7890这里表示主机的7890端口,使用主机的7890进行容器环境的系统代理
  4. 修改searxng/settings.yml内容如下

    # see https://docs.searxng.org/admin/settings/settings.html#settings-use-default-settingsuse_default_settings: true general: debug: true engines: # 启用默认禁用的引擎 - name: bing disabled: false - name: bilibili engine: bilibili shortcut: bil disabled: false # 禁用默认启用的引擎 - name: arch linux wiki engine: archlinux disabled: true - name: duckduckgo engine: duckduckgo distabled: true - name: github engine: github shortcut: gh disabled: true - name: wikipedia engine: wikipedia disabled: trueserver: # base_url is defined in the SEARXNG_BASE_URL environment variable, see .env and docker-compose.yml secret_key: \"ultrajhjhjhjhyubwdwdwsbecretkey\" # change this! 这里一定要修改 limiter: false # can be disabled for a private instance image_proxy: truesearch: formats: - html - json # 允许以 json 形式返回结果ui: static_use_hash: trueoutgoing: proxies: \"http://172.17.0.1:7890\" # 与 docker-compose 中的 IP 一致 request_timeout: 10.0 # 延长超时时间 max_retries: 3
    1. 修改返回结果添加json
    2. outgoing部分强制Searxng应用程序走代理
  5. 构建并运行

    docker-compose up -d
  6. 访问http://192.168.231:3001,该为自己上面填的

  7. 然后在open-webuisearxng地址填写为

    http://ip:port?q=&format=json

其它Web-Search

  1. 使用google_pse,需要对open-webui设置代理,可以直接在环境变量设置 🌍 Environment Variable Configuration | Open WebUI

    内置的google_pse API解决方案过程很简单,

    1.登录google开发者账号(有Google账号可以直接一键注册) https://developers.google.com/custom-search

    2.接着去可编程搜索引擎(pse)控制面板里添加一个自定义搜索引擎 https://programmablesearchengine.google.com/controlpanel/all

    3.点获取密钥就能拿api密钥了(这个记得存起来) https://developers.google.com/custom-search/v1/introduction

    4.回到控制面板再点创建的就能拿到搜索引擎ID了 https://programmablesearchengine.google.com/controlpanel/all

    5.把东西填上去就好了(默认联网功能是关的,要用的时候顺手开下)

  2. 使用国内博查的web-search,通过添加社区工具实现 Web Search using Bocha Search API Tool | Open WebUI Community

  3. 推荐一个DeepSeek-R1的函数,可以显示思考过程https://openwebui.com/f/zgccrui/deepseek_r1,后面是教程链接:OpenWebUI 添加 DeepSeek 思维链和联网 API_哔哩哔哩_bilibili

参考文章

  1. 私有化部署 SearXNG 实现 DeepSeek+Open-WebUI 联网搜索功能 - 志文工作室
  2. 大模型本地化部署(Ollama + Open-WebUI)_open webui-CSDN博客
  3. 使用SearXNG-搭建个人搜索引擎(附国内可用Docker镜像源)-CSDN博客
  4. searxng-docker/searxng/settings.yml at master · searxng/searxng-docker
  5. SearXNG | Open WebUI
  6. Google PSE | Open WebUI
  7. 🔄 Updating Open WebUI | Open WebUI
  8. 本地部署大模型openwebui(ollama部署的deepseetR1)联网搜索的一种解决方案 - hai(。・∀・)ノ゙ - 博客园
  9. Web Search using Bocha Search API Tool | Open WebUI Community
  10. OpenWebUI 添加 DeepSeek 思维链和联网 API_哔哩哔哩_bilibili
  11. 【知识科普】【纯本地化搭建】【不本地也行】DeepSeek + RAGFlow 构建个人知识库_哔哩哔哩_bilibili