Writing Skills
writing-skills
效率与协作技能,来自 obra/superpowers,查看原文获取完整用途和操作说明。
deploy-searxng【部署与运维】通过 Docker Compose 部署自托管的 SearXNG 元搜索引擎。涵盖 settings.yml 配置、 搜索引擎选择、结果代理、Nginx 前端、持久化和更新。适用于搭建无追踪的私有搜索引擎、 聚合多个搜索提供者的结果、为团队或组织运行共享搜索实例,或替代对单一搜索提供者的依赖。
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
使用 Docker Compose 和 Nginx 部署自托管的 SearXNG 元搜索引擎。
mkdir -p searxng/{config,nginx}
cd searxng
docker-compose.yml:
services:
searxng:
image: searxng/searxng:latest
container_name: searxng
volumes:
- ./config:/etc/searxng:rw
environment:
- SEARXNG_BASE_URL=https://search.example.com/
cap_drop:
- ALL
cap_add:
- CHOWN
- SETGID
- SETUID
restart: unless-stopped
networks:
- searxng
nginx:
image: nginx:1.27-alpine
container_name: searxng-nginx
ports:
- "8080:80"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- searxng
restart: unless-stopped
networks:
- searxng
networks:
searxng:
driver: bridge
config/settings.yml:
use_default_settings: true
general:
instance_name: "My SearXNG"
privacypolicy_url: false
contact_url: false
search:
safe_search: 0
autocomplete: "google"
default_lang: "en"
server:
secret_key: "generate-a-random-secret-key-here"
limiter: true
image_proxy: true
port: 8080
bind_address: "0.0.0.0"
ui:
static_use_hash: true
default_theme: simple
infinite_scroll: true
engines:
- name: google
engine: google
shortcut: g
disabled: false
- name: duckduckgo
engine: duckduckgo
shortcut: ddg
disabled: false
- name: wikipedia
engine: wikipedia
shortcut: wp
disabled: false
- name: github
engine: github
shortcut: gh
disabled: false
- name: stackoverflow
engine: stackoverflow
shortcut: so
disabled: false
- name: arxiv
engine: arxiv
shortcut: arx
disabled: false
生成密钥:
openssl rand -hex 32
nginx/nginx.conf:
events {
worker_connections 1024;
}
http {
server {
listen 80;
location / {
proxy_pass http://searxng:8080;
proxy_set_header Host $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 $scheme;
proxy_set_header Connection "";
proxy_buffering off;
}
location /static/ {
proxy_pass http://searxng:8080/static/;
expires 1y;
add_header Cache-Control "public, immutable";
}
}
}
config/limiter.toml:
[botdetection.ip_limit]
link_token = true
[botdetection.ip_lists]
block_ip = []
pass_ip = ["127.0.0.1/8", "::1/128"]
pass_searxng_org = false
# Start the stack
docker compose up -d
# Check logs
docker compose logs -f searxng
# Verify it's running
curl -s http://localhost:8080 | head -5
# Test a search
curl -s "http://localhost:8080/search?q=test&format=json" | head -20
预期结果: SearXNG 通过 Nginx 在端口 8080 上响应。搜索查询返回聚合结果。
失败处理: 检查 docker compose logs searxng 中的配置错误。验证 settings.yml 的 YAML 语法。
对于公开部署,添加 SSL 终止。更新 docker-compose.yml:
services:
nginx:
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/nginx-ssl.conf:/etc/nginx/nginx.conf:ro
- certbot-certs:/etc/letsencrypt:ro
- certbot-webroot:/var/www/certbot:ro
certbot:
image: certbot/certbot
volumes:
- certbot-certs:/etc/letsencrypt
- certbot-webroot:/var/www/certbot
volumes:
certbot-certs:
certbot-webroot:
完整的 SSL Nginx 配置请参见 configure-nginx 技能。
# Pull latest image
docker compose pull searxng
# Restart with new image
docker compose up -d
# Backup configuration
cp -r config/ config-backup-$(date +%Y%m%d)/
settings.yml 中的 secret_key 将拒绝启动:rw 而非 :rosettings.yml 对缩进敏感。部署前使用 YAML 检查器验证SEARXNG_BASE_URL 必须与用户实际访问的 URL 匹配,包括协议和尾部斜杠setup-compose-stack — 此处使用的通用 Docker Compose 模式configure-nginx — Nginx 的 SSL 和安全头配置configure-reverse-proxy — Nginx 前端的高级代理模式