Open WebUI结合代理过的Searxng实现联网搜索
本身Searxng
SearXNG | Open WebUI是一款多搜索引擎合在一起的浏览器,整体使用下来比google_pse
Google PSE | Open WebUI引擎好用
特别注意:
- 使用
Searxng
需要对运行Searxng
的容器设置代理,理论上无需对Open WebUI
的容器设置主机网络代理,但在实际过程中,有观察到日志个别网站连接超时,且会不时请求下github版本,因此我都加了主机代理 - 使用
google_pse
则是由Open WebUI
容器进行访问,需要设置主机代理 - 我的本机有http://127.0.0.1:7890的代理,后续有使用
本地环境
系统环境以及软件环境如下
centos 7.6
open-webui v0.5.16
docker 20.10.5
- 1
- 2
- 3
安装Open WebUI
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-webui
networks:
proxy-net:
driver: bridge
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
注: 这里安装了watchtower
进行监控自动更新Open WebUI
,由于使用的ghcr.io/open-webui/open-webui:latest
镜像,因此也需要设置代理否则会连接超时导致更新失败
watchtower使用参考:🔄 Updating Open WebUI | Open WebUI
安装Searxng
-
拉取代码
git clone https://github.com/searxng/searxng-docker.git
- 1
-
进入仓库
cd searxng-docker
- 1
-
修改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
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 俩个
3001
端口要一致 - 使用的是本机的IPv4地址,或者是服务器公网IP
- http_proxy=http://172.17.0.1:7890这里表示主机的7890端口,使用主机的7890进行容器环境的系统代理
-
修改
searxng/settings.yml
内容如下# see https://docs.searxng.org/admin/settings/settings.html#settings-use-default-settings use_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: true server: # 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: true search: formats: - html - json # 允许以 json 形式返回结果 ui: static_use_hash: true outgoing: proxies: "http://172.17.0.1:7890" # 与 docker-compose 中的 IP 一致 request_timeout: 10.0 # 延长超时时间 max_retries: 3
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 修改返回结果添加
json
outgoing
部分强制Searxng
应用程序走代理
-
构建并运行
docker-compose up -d
- 1
-
访问http://192.168.231:3001,该为自己上面填的
-
然后在
open-webui
中searxng
地址填写为http://ip:port?q=
&format=json
其它Web-Search
-
使用
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.把东西填上去就好了(默认联网功能是关的,要用的时候顺手开下)
-
使用国内博查的
web-search
,通过添加社区工具实现 Web Search using Bocha Search API Tool | Open WebUI Community -
推荐一个
DeepSeek-R1
的函数,可以显示思考过程https://openwebui.com/f/zgccrui/deepseek_r1,后面是教程链接:OpenWebUI 添加 DeepSeek 思维链和联网 API_哔哩哔哩_bilibili
参考文章
- 私有化部署 SearXNG 实现 DeepSeek+Open-WebUI 联网搜索功能 - 志文工作室
- 大模型本地化部署(Ollama + Open-WebUI)_open webui-CSDN博客
- 使用SearXNG-搭建个人搜索引擎(附国内可用Docker镜像源)-CSDN博客
- searxng-docker/searxng/settings.yml at master · searxng/searxng-docker
- SearXNG | Open WebUI
- Google PSE | Open WebUI
- 🔄 Updating Open WebUI | Open WebUI
- 本地部署大模型openwebui(ollama部署的deepseetR1)联网搜索的一种解决方案 - hai(。・∀・)ノ゙ - 博客园
- Web Search using Bocha Search API Tool | Open WebUI Community
- OpenWebUI 添加 DeepSeek 思维链和联网 API_哔哩哔哩_bilibili
- 【知识科普】【纯本地化搭建】【不本地也行】DeepSeek + RAGFlow 构建个人知识库_哔哩哔哩_bilibili
评论记录:
回复评论: