使用Docker实现客户化本地部署集成搜索引擎SearXNG
使用前提:已安装Docker软件,并设置docker下载的国内镜像源,本机可毗连互联网,使用谷歌搜索需科学上网,用于Dify等第三方调用,需增加son输特别式。[*]到Searxng公司开发的Docker在GitHub的网站(https://github.com/searxng/searxng-docker)下载zip包,并解压到指定文件夹。
https://i-blog.csdnimg.cn/direct/db6eae8aa3524e92bda56073f84f67ba.png
2、打开该文件夹,修改docker-compose.yaml,重点修改Caddy和端口两处,不使用反向署理注释或删除caddy相关内容,包括 #volumes中caddy相关的内容,端口按需修改。
https://i-blog.csdnimg.cn/direct/3b0b9774b2fa4a8992faafcceee2e375.png
https://i-blog.csdnimg.cn/direct/6966e2a3df2d4903a49ad9dcece8a387.png
完备docker-compose.yaml代码:
version: "3.7"
services:
# 不使用反向代理注释掉或删除caddy相关内容,包括 下面volumes中caddy:相关的内容
#caddy:
#container_name: caddy
#image: docker.io/library/caddy:2-alpine
#network_mode: host
#restart: unless-stopped
#volumes:
# - ./Caddyfile:/etc/caddy/Caddyfile:ro
# - caddy-data:/data:rw
# - caddy-config:/config:rw
#environment:
# - SEARXNG_HOSTNAME=${SEARXNG_HOSTNAME:-http://localhost}
# - SEARXNG_TLS=${LETSENCRYPT_EMAIL:-internal}
#cap_drop:
# - ALL
#cap_add:
# - NET_BIND_SERVICE
#logging:
# driver: "json-file"
# options:
# max-size: "1m"
# max-file: "1"
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
cap_drop:
- ALL
cap_add:
- SETGID
- SETUID
- DAC_OVERRIDE
logging:
driver: "json-file"
options:
max-size: "1m"
max-file: "1"
searxng:
container_name: searxng
image: docker.io/searxng/searxng:latest
restart: unless-stopped
networks:
- searxng
ports:
- "8081:8080" # 去掉127.0.0.1,还有冒号前端口为对外提供服务口,如不冲突可以不该
volumes:
- ./searxng:/etc/searxng:rw
environment:
- SEARXNG_BASE_URL=https://${SEARXNG_HOSTNAME:-localhost}/
- UWSGI_WORKERS=${SEARXNG_UWSGI_WORKERS:-4}
- UWSGI_THREADS=${SEARXNG_UWSGI_THREADS:-4}
cap_drop:
- ALL
cap_add:
- CHOWN
- SETGID
- SETUID
logging:
driver: "json-file"
options:
max-size: "1m"
max-file: "1"
networks:
searxng:
volumes:
#caddy-data:
#caddy-config:
valkey-data2:
3、修改searxng子文件夹下settings.yml文件:general:选项,修改调试模式为: false,客户化网页标题名称 instance_name: "MySou" #网页标题名称;server:修改 secret_key:为自己的暗码,将图片署理设置为:ture;search选项:将主动完成输入改成百度(baidu),默认搜索语言 default_lang设置为中文 "zh-CN",格式增加json,方便Dify等第三方软件调用;ui选项:将主动完成输入改成百度(baidu),将UI页面默认改为中文("zh-Hans-CN" ),将页面风格 simple_style:选为自己的,有亮light、暗 dark、主动auto可选。
https://i-blog.csdnimg.cn/direct/068207ec7001453bb27eae5cd06d5f72.png
接着请搜索引擎选择方面,将百度、360搜索设置为启用,并按需禁用无效的搜索引擎
https://i-blog.csdnimg.cn/direct/ad1b8e35f9924bf1a90f25a67b33f7d5.png
最后按需设置搜索分类,如图只保存了综合、图片、视频、新闻四类。
https://i-blog.csdnimg.cn/direct/721b1fde4c9b47e5a8b62147c57a38a0.png
特别提示,文件对其格式必须严格,种别标签必须顶头靠左,避免出现内部错误。详细设置建议查看 https://docs.searxng.org/admin/settings/settings.html 文档
# 详细查看 https://docs.searxng.org/admin/settings/settings.html 文档
use_default_settings: true
general:
debug: false
instance_name: "MySou" #网页标题名称
server:
secret_key: "myultrasecretkey"#这里要修改成自己的
limiter: false
image_proxy: true
search:
autocomplete: "baidu" #输入框联想自动完成
default_lang: "zh-CN" #默认中文
formats:
- html
- json # 允许以 json 形式返回结果
ui:
static_use_hash: true
default_locale: "zh-Hans-CN"#UI界面默认中文
theme_args:
# 页面风格: auto, light, dark
simple_style: auto
engines:
# 启用默认禁用的引擎
- name: bing
engine: bing
shortcut: bi
timeout: 5.0
disabled: false
- name: bing images
engine: bing_images
shortcut: bii
- name: bing news
engine: bing_news
shortcut: bin
- name: bilibili
engine: bilibili
shortcut: bil
timeout: 5.0
disabled: false
# 360 搜索
- name: 360search
engine: 360search
shortcut: 360so
timeout: 5.0
disabled: false
# 百度
- name: baidu
engine: baidu
shortcut: baidu
timeout: 5.0
disabled: false
- name: baidu images
baidu_category: images
categories:
engine: baidu
shortcut: bdi
disabled: false
- name: baidu kaifa
baidu_category: it
categories:
engine: baidu
shortcut: bdk
disabled: false
# 搜狗
- name: sogou
engine: sogou
shortcut: sogou
timeout: 5.0 # 搜狗有点慢,需要额外加点超时时长
# 爱奇艺
- name: iqiyi
engine: iqiyi
shortcut: iq
# 搜狗视频
- name: sogou_video
engine: sogou_video
shortcut: sogouv
# 搜狗|微信
- name: sogou wechat
engine: sogou_wechat
short: sogouw
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
- name: currency
engine: currency_convert
categories: general
shortcut: cc
disabled: true
- name: startpage
engine: startpage
shortcut: sp
disabled: true
- name: qwant
qwant_categ: web
engine: qwant
shortcut: qw
disabled: true
- name: dictzone
engine: dictzone
shortcut: dc
disabled: true
- name: lingva
engine: lingva
shortcut: lv
disabled: true
- name: mymemory translated
engine: translated
shortcut: tl
timeout: 5.0
disabled: true
- name: brave
engine: brave
shortcut: br
disabled: true
- name: duckduckgo
engine: duckduckgo
shortcut: ddg
disabled: true
- name: wikidata
engine: wikidata
shortcut: wd
disabled: true
redis:
url: redis://redis:6379/0
categories_as_tabs:
general: #综合
images: #图片
videos: #视频
news: #新闻
#map: #地图
#music: #音乐
#it: #信息技术
#science: #科学
#files: #文件
#social media: #社会媒体
4、设置完成后在saerxng-docker文件夹点击在终端打开,在终端窗口下输入命令:docker-compose up -d,等候拉取镜像,直至拉取完毕并启动镜像。
https://i-blog.csdnimg.cn/direct/6adeefcb8c824b80a4e20364981be2dc.png
https://i-blog.csdnimg.cn/direct/7d6b5ccf5db54391832fc41b5e7a12ef.png
5、在Docker软件中查看容器,点击端口可进入访问页面,页面一默认为中文,标题已经改为设定的Mysou,搜索主动完成启用。
https://i-blog.csdnimg.cn/direct/2cdf1a813f6e423bb28e2164ea82ebc6.png
https://i-blog.csdnimg.cn/direct/8aa38eb1219e47ce8e60a82b4e36a50e.png
https://i-blog.csdnimg.cn/direct/a02f3931685046f8bba87e896d57d17f.png
题外:网上搜索很多多少大侠写的文档里提到如下参数,但官方文档没有找到,不知为什么,渴望不是相互抄作业抄错了,有知道用途的欢迎留言批评指正,谢谢。
ratelimit:
enabled: true
per_second: 5
per_minute: 60
https://i-blog.csdnimg.cn/direct/7c8d02c7bc684763a02db6d18bbca96b.png
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]