准备工作
操作系统
CentOS Stream 9 (x86)cat /etc/os-release NAME="CentOS Stream" VERSION="9" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="9" PLATFORM_ID="platform:el9" PRETTY_NAME="CentOS Stream 9" ANSI_COLOR="0;31" LOGO="fedora-logo-icon" CPE_NAME="cpe:/o:centos:centos:9" HOME_URL="https://centos.org/" BUG_REPORT_URL="https://issues.redhat.com/" REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 9" REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"已安装docker compose
Docker version 29.5.3, build d1c06ef Docker Compose version v5.1.4- SearXNG tag版本号为
2026.6.17-4dfdc822c
一、目录结构
SearXNG/
├── docker-compose.yml
└── searxng-config/
└── settings.yml
二、创建配置文件
mkdir -p SearXNG/searxng-config/ && cd SearXNGcat > docker-compose.yml << 'EOF'
services:
searxng:
image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/searxng/searxng:2026.6.17-4dfdc822c
container_name: searxng
ports:
- "18080:8080" # 将宿主机的18080端口映射到容器的8080端口
volumes:
- ./searxng-config:/etc/searxng # 持久化配置文件,方便后续自定义设置
environment:
- BASE_URL=http://localhost:18080 # 设置基础URL,确保API调用正确
- INSTANCE_NAME=my-searxng # 实例名称,用于标识你的搜索服务
- SEARXNG_SECRET=your-secret-key-here # 强烈建议替换为你的随机密钥,增强安全性
restart: always # 容器异常退出后自动重启
EOFcat > searxng-config/settings.yml << 'EOF'
use_default_settings: true
server:
secret_key: "5dibmPP2UapoQ0NsvmPHZcabgr1QLgCS"
image_proxy: true
search:
formats:
- html
- json
default_engines:
- baidu
engines:
# 1. 国内可用及保留的搜索引擎 (已启用)
- name: baidu
engine: baidu
shortcut: bd
disabled: false
- name: sogou
engine: sogou
shortcut: sogou
timeout: 5.0
disabled: false
- name: 360search
engine: 360search
shortcut: 360so
disabled: false
- name: quark
engine: quark
shortcut: qk
disabled: false
- name: bing
engine: bing
shortcut: bi
disabled: false
- name: bilibili
engine: bilibili
shortcut: bil
disabled: false
- name: sogou_video
engine: sogou_video
shortcut: sogouv
disabled: false
- name: sogou_wechat
engine: sogou_wechat
shortcut: sogouw
disabled: false
# 2. 你要求禁用的搜索引擎 (已禁用)
- name: brave
engine: brave
shortcut: br
disabled: true
- name: duckduckgo
engine: duckduckgo
shortcut: ddg
disabled: true
- name: google
engine: google
shortcut: go
disabled: true
- name: startpage
engine: startpage
shortcut: sp
disabled: true
- name: wikipedia
engine: wikipedia
shortcut: wp
disabled: true
EOF三、启动SearXNG
docker compose up -d正常启动后可以访问http://localhost:18080来访问后台管理web
四、测试接口
curl测试json格式api
curl -s "http://10.101.83.124:18080/search?q=今天天气如何&format=json" | jq .正常结果如下
{
"query": "今天天气如何",
"results": [
{
"title": "广州天气预报,广州7天天气预报,广州15天天气预报,广州天气查询",
"url": "http://www.src.weather.com.cn/weather/101280101.shtml",
"content": "2026年5月28日 - 蓝天预报综合天气现象、能见度、空气质量等因子,预测未来一周的天空状况。.35/27°C广州香江野生动物世界/...",
"engine": "360search",
"template": "default.html",
"parsed_url": [
"http",
"www.src.weather.com.cn",
"/weather/101280101.shtml",
...