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

发布于:2025-07-11 ⋅ 阅读:(19) ⋅ 点赞:(0)

先看一下 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: redis
    image: docker.io/valkey/valkey:8-alpine
    command: valkey-server --save 30 1 --loglevel warning
    restart: unless-stopped
    networks:
      - searxng
    volumes:
      - valkey-data2:/data
    logging:
      driver: "json-file"
      options:
        max-size: "1m"
        max-file: "1"

  searxng:
    container_name: searxng
    image: searxng/searxng:latest
    restart: unless-stopped
    networks:
      - searxng
    ports:
      - "0.0.0.0:8080:8080"
    volumes:
      - engines-file:/usr/local/searxng/searx/engines  #这里将搜引擎目录持久化出来 是因为searxng docker镜像默是缺失国内搜索引擎的配置的
      - ./searxng:/etc/searxng:rw
    environment:
      - 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.yml
    logging:
      driver: "json-file"
      options:
        max-size: "1m"
        max-file: "1"

networks:
  searxng:

#卷持久化路径需要配置一下 不了解可以问一下ai都是什么意思
volumes:
  valkey-data2:
   driver: local
   driver_opts:
     type: none
     o: bind
     device: /data/searxng-docker/redis/valkey 

  engines-file:
   driver: local
   driver_opts:
     type: none
     o: bind
     device: /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.yml
  secret_key: "34788b49b8f9d819cfcb09da447b0d8586c63ad1acd469a1e446"    #这个可以复用 也可以自己生成
  limiter: false
  image_proxy: true
ui:
  static_use_hash: true
redis:
  url: redis://redis:6379/0
search:
  formats:
    - html
    - json   ##开启json模式 方便被llm调用

engines:
# 启用默认禁用的国内引擎
  - name: baidu
    categories:
      - web
      - news
      - general
    engine: baidu
    shortcut: bd
    timeout: 9.0
    disabled: false


  - name: 360search
    categories:
      - web
      - news
      - general
    engine: 360search
    shortcut: 360so
    timeout: 9.0
    disabled: false



# 禁用默认启用的外国搜索引擎
  - name: archlinuxwiki
    engine: archlinux
    disabled: true
  - name: duckduckgo
    engine: duckduckgo
    distabled: true
  - name: github
    engine: github
    shortcut: gh
    disabled: true
  - name: wikipedia
    engine: wikipedia
    disabled: true
  - name: wikidata
    engine: wikidata
    disabled: true
  - name: google
    engine: google
    disabled: true
  - name: youtube
    engine: youtube_noapi
    disabled: true
  - name: duckduckgo
    engine: duckduckgo
    disabled: true
  - name: qwant
    engine: qwant
    disabled: true
  - name: brave
    engine: brave
    disabled: true
  - name: startpage
    engine: startpage
    disabled: true
  - name: currency
    engine: currency
    disabled: 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>

之后测试对话:


网站公告

今日签到

点亮在社区的每一天
去签到