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

searxng 对接openweb-UI实现大模型通过国内搜索引擎在线搜索

先看一下 qwen3-4b模型的效果

SearXNG简介:SearXNG 是一个免费的互联网元搜索引擎,它汇总了来自各种搜索服务和数据库的结果。用户既不会被跟踪,也不会被分析。

官方项目:https://github.com/searxng/searxng-docker

项目文档:https://docs.searxng.org

open-webui简介:Open WebUI 是一个可扩展、功能丰富且用户友好的自托管 AI 平台,旨在完全离线运行。它支持各种 LLM 运行器,如 Ollama 和 OpenAI 兼容的 API,并内置了 RAG 推理引擎,使其成为强大的 AI 部署解决方案。

官方项目:https://github.com/open-webui/open-webui

项目文档:⭐ Features | Open WebUI

安装部署

open-webui的安装方法非常简单

命令行安装:

#安装
pip install open-webui
#运行
open-webui serve
#这将启动 Open WebUI 服务器,您可以在 http://localhost:8080

open-webui的使用可以参考项目文档

docker安装:

docker run -d -p 3000:8080  -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main

如何与模型对接也可以参考我的其它文档: 快速搭建大模型web对话环境指南(open-webUI)_大模型 webui 框架-CSDN博客

本次文档主要介绍searxng安装与使用

searxng 安装是支持 k8s 部署 docker compose部署 与命令行脚本安装或手动安装

本人都体验了一下

k8s是通过helm安装的,项目地址: https://github.com/searxng/searxng-helm-chart 该项目更新貌似不积极,而且也不是装好就能用也需要调整,适合k8s能力强者部署

命令行手动与脚本安装 需要提前准备好centos9 或ubuntu22以及以上的系统 python3.10以上环境才能安装成功,也需要自己配置nginx代理 自己配置开机自启动,而且容易很多报错,适合动手动能力强体验一下 参考官方文档:Installation Script — SearXNG Documentation (2025.7.9+2fe854090)

本次文档介绍docker compose安装 简单方便

官方配置:https://github.com/searxng/searxng-docker/blob/master/docker-compose.yaml

(文档建立在默认配置好docker环境的服务器中,并有能力拉取dockerhub镜像仓库)

进入searxng-docker项目目录后 修改docker-compose.yaml 文件配置

本次配置做了一些修改:

删除了caddy相关配置,这是一个类似nginx的反向代理服务,这个一般企业内安装是不需要的,根据个人所需决定是否安装

version: "3.7"services:redis:container_name: redisimage: docker.io/valkey/valkey:8-alpinecommand: valkey-server --save 30 1 --loglevel warningrestart: unless-stoppednetworks:- searxngvolumes:- valkey-data2:/datalogging:driver: "json-file"options:max-size: "1m"max-file: "1"searxng:container_name: searxngimage: searxng/searxng:latestrestart: unless-stoppednetworks:- searxngports:- "0.0.0.0:8080:8080"volumes:- engines-file:/usr/local/searxng/searx/engines  #这里将搜引擎目录持久化出来 是因为searxng docker镜像默是缺失国内搜索引擎的配置的- ./searxng:/etc/searxng:rwenvironment:- SEARXNG_BASE_URL=https://${SEARXNG_HOSTNAME:-localhost}/- UWSGI_WORKERS=${SEARXNG_UWSGI_WORKERS:-4}- UWSGI_THREADS=${SEARXNG_UWSGI_THREADS:-4}- SEARXNG_SETTINGS_PATH=/etc/searxng/settings.ymllogging:driver: "json-file"options:max-size: "1m"max-file: "1"networks:searxng:#卷持久化路径需要配置一下 不了解可以问一下ai都是什么意思
volumes:valkey-data2:driver: localdriver_opts:type: noneo: binddevice: /data/searxng-docker/redis/valkey engines-file:driver: localdriver_opts:type: noneo: binddevice: /data/searxng-docker/engines-file

修改配置文件searxng-docker/searxng/settings.yml (这是一次正确配置 大家可以参考)

# see https://docs.searxng.org/admin/settings/settings.html#settings-use-default-settings
use_default_settings: true
server:# base_url is defined in the SEARXNG_BASE_URL environment variable, see .env and docker-compose.ymlsecret_key: "34788b49b8f9d819cfcb09da447b0d8586c63ad1acd469a1e446"    #这个可以复用 也可以自己生成limiter: falseimage_proxy: true
ui:static_use_hash: true
redis:url: redis://redis:6379/0
search:formats:- html- json   ##开启json模式 方便被llm调用engines:
# 启用默认禁用的国内引擎- name: baiducategories:- web- news- generalengine: baidushortcut: bdtimeout: 9.0disabled: false- name: 360searchcategories:- web- news- generalengine: 360searchshortcut: 360sotimeout: 9.0disabled: false# 禁用默认启用的外国搜索引擎- name: archlinuxwikiengine: archlinuxdisabled: true- name: duckduckgoengine: duckduckgodistabled: true- name: githubengine: githubshortcut: ghdisabled: true- name: wikipediaengine: wikipediadisabled: true- name: wikidataengine: wikidatadisabled: true- name: googleengine: googledisabled: true- name: youtubeengine: youtube_noapidisabled: true- name: duckduckgoengine: duckduckgodisabled: true- name: qwantengine: qwantdisabled: true- name: braveengine: bravedisabled: true- name: startpageengine: startpagedisabled: true- name: currencyengine: currencydisabled: true

这里重点说一下 searxng/searxng:latest 这个镜像 是没有自带国内搜索引擎的,看网上很多人并不需要特殊配置就可以用国内引擎,我是存疑的

会报错

Errno 2] No such file or directory: '/usr/local/searxng/searx/engines/baidu.py

这也是为什么我将engines-file:/usr/local/searxng/searx/engines 持久化到/data/searxng-docker/engines-file

尝试第一次启动:

docker compose up -d

之后访问该机器8080端口 可以看到如下页面:

配置默认国内搜索引擎

点击首选项

查看搜索引擎

确认是否有国内的搜索引擎

如果没有就需要将 国内的引擎配置文件导入 (另外 上图首选项的哪些配置只保存在客户端的cookie中,并不是全局生效的)

导入步骤如下:

打开项目:https://github.com/searxng/searxng-docker/tree/master/searxng

找到引擎文件 并下载

将下载好的引擎导入到容器持久化目录/data/searxng-docker/engines-file

重启容器:

docker compose stop
docker compose up -d

再次确认国内引擎是否可以选中

确认搜索内容 引擎加载正常

之后打开open-webui 设置-管理员设置-联网搜索-searxng查询URL

http://<IP地址或域名>:8080/search?q=<query>

之后测试对话:

http://www.xdnf.cn/news/15192.html

相关文章:

  • 通过 .NET Aspire 使用本地 AI 模型
  • 从 SEO 到 GEO:2025 电商搜索新战场|产品 SERP 的 AI 征服指南
  • Docker的/var/lib/docker/目录占用100%的处理方法
  • esp8266-01S实现PPM波形
  • Linux指令与权限
  • SQL138 连续两次作答试卷的最大时间窗
  • 【C语言】学习过程教训与经验杂谈:思想准备、知识回顾(六)
  • Flask 入门教程:用 Python 快速搭建你的第一个 Web 应用
  • kotlin中集合的用法
  • nmap扫描指定网段中指定开放端口的主机(IP,mac地址)
  • wps怎样正常显示毫秒时间
  • Spring Boot 与 Docker 的完美结合:容器化你的应用
  • 深入理解区块链 | 去中心化架构与密码学保障
  • html的outline: none;
  • 杰赛S65_中星微ZX296716免拆刷机教程解决网络错误和时钟问题
  • 智能体决策机制深度剖析:ReAct、Plan-and-Execute与自适应策略
  • Linux 服务器挖矿病毒深度处理与防护指南
  • 数字孪生技术为UI前端赋能:实现产品设计的快速原型验证
  • SDR(软件定义无线电)与软件定义声学系统详解
  • Idea如何解决包冲突
  • Unreal Engine 自动设置图像
  • Docker高级管理
  • C++面试冲刺笔记1:虚函数的基本工作原理
  • Java项目集成Log4j2全攻略
  • 【深度学习】【入门】Sequential的使用和简单神经网络搭建
  • 一天一道Sql题(day05)
  • 计蒜客T3473丑数、Leetcode2401最长优雅子数组、Leetcode167两数之和、Leetcode581最短无序连续子数组
  • Python Day8
  • 第6章应用题
  • C++内存泄露排查