共计 2417 个字符,预计需要花费 7 分钟才能阅读完成。
背景
Lobechat 新版本支持联网查询 github.com/lobehub/lobe-chat/discussions/6447。
联网查询依赖 SearXNG,于是着手进行私有化部署。
SearXNG 是什么
SearXNG 是一个免费的互联网元搜索引擎,它汇总了来自 70 多个搜索服务的结果。用户既不被跟踪也不被分析。
SearXNG 如何保护隐私:
无论实例的类型(私有、公共)如何,SearXNG 都以多种方式保护其用户的隐私。从搜索请求中删除私人数据有三种形式:
- 从前往搜索服务的请求中删除私人数据
- 不通过搜索服务(例如广告)转发来自第三方服务的任何内容
- 从转到结果页面的请求中删除私有数据
删除私人数据意味着不向外部搜索引擎发送 cookie 并为每个请求生成随机浏览器配置文件。因此,公共或私有实例是否处理请求并不重要,因为它在两种情况下都是匿名的。IP 地址将是实例的 IP。
与大多数搜索服务不同,SearXNG 不提供广告或跟踪内容。因此,私人数据不会转发给可能将其货币化的第三方。除了保护用户免受搜索服务之外,引用页面和搜索查询都对访问的结果页面隐藏。
部署
官方支持多种部署方式,下文以 docker-compose 为例。
Docker Compose
由于已经有 Nginx 实例作为入口,不需要项目中集成的Caddy。
# 拉取项目
mkdir /usr/local/searxng/ && cd /usr/local/searxng/
git clone https://github.com/searxng/searxng-docker.git
# 编辑配置文件
cd searxng-docker/
# 删除caddy相关配置
# cat docker-compose.yaml
version: "3.7"
services:
redis:
container_name: searxng-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:
- "8085:8080"
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:
valkey-data2:
# 修改配置参数,lobechat需要增加json支持
# vim searxng/settings.yml
# see https://docs.searxng.org/admin/settings/settings.html#settings-use-default-settings
use_default_settings: false
server:
# base_url is defined in the SEARXNG_BASE_URL environment variable, see .env and docker-compose.yml
secret_key: "test123123123" # change this!
# 关闭限制器,否则极易触发限制导致 429 TOO MANY REQUESTS
limiter: false # can be disabled for a private instance
image_proxy: true
ui:
static_use_hash: true
redis:
url: redis://redis:6379/0
# lobechat需要json支持
search:
formats:
- html
- json
Nginx 反代
# vim ****.conf
upstream searxng-web {
server 192.168.2.11:8085;
}
server {
listen 80;
server_name ***.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
http2 on;
server_name ***.com;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_redirect http:// https://;
proxy_pass http://searxng-web;
}
}
检验
本文属于专题:AI应用
- AI助手 LobeChat
- 开源搜索引擎 SearXNG
引用链接
正文完