forked from DevOps/deploy.stack
feat(searxng): 添加Caddy配置文件
添加stack.yml用于定义SearXNG和Redis的docker-compose服务配置 添加Caddyfile作为反向代理配置,包含安全头设置和缓存策略
This commit is contained in:
91
searxng/Caddyfile
Normal file
91
searxng/Caddyfile
Normal file
@@ -0,0 +1,91 @@
|
||||
{
|
||||
admin off
|
||||
|
||||
log {
|
||||
output stderr
|
||||
format filter {
|
||||
# Preserves first 8 bits from IPv4 and 32 bits from IPv6
|
||||
request>remote_ip ip_mask 8 32
|
||||
request>client_ip ip_mask 8 32
|
||||
|
||||
# Remove identificable information
|
||||
request>remote_port delete
|
||||
request>headers delete
|
||||
request>uri query {
|
||||
delete url
|
||||
delete h
|
||||
delete q
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
servers {
|
||||
client_ip_headers X-Forwarded-For X-Real-IP
|
||||
|
||||
# Allow the following IP to passthrough the "X-Forwarded-*" headers to SearXNG
|
||||
# https://caddyserver.com/docs/caddyfile/options#trusted-proxies
|
||||
trusted_proxies static private_ranges
|
||||
trusted_proxies_strict
|
||||
}
|
||||
}
|
||||
|
||||
{$SEARXNG_HOSTNAME}
|
||||
|
||||
tls {$SEARXNG_TLS}
|
||||
|
||||
encode zstd gzip
|
||||
|
||||
@api {
|
||||
path /config
|
||||
path /healthz
|
||||
path /stats/errors
|
||||
path /stats/checker
|
||||
}
|
||||
|
||||
@static {
|
||||
path /static/*
|
||||
}
|
||||
|
||||
@imageproxy {
|
||||
path /image_proxy
|
||||
}
|
||||
|
||||
header {
|
||||
# CSP (https://content-security-policy.com)
|
||||
Content-Security-Policy "upgrade-insecure-requests; default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; form-action 'self' https:; font-src 'self'; frame-ancestors 'self'; base-uri 'self'; connect-src 'self'; img-src * data:; frame-src https:;"
|
||||
|
||||
# Disable browser features
|
||||
Permissions-Policy "accelerometer=(),camera=(),geolocation=(),gyroscope=(),magnetometer=(),microphone=(),payment=(),usb=()"
|
||||
|
||||
# Only allow same-origin requests
|
||||
Referrer-Policy "same-origin"
|
||||
|
||||
# Prevent MIME type sniffing from the declared Content-Type
|
||||
X-Content-Type-Options "nosniff"
|
||||
|
||||
# Comment header to allow indexing by search engines
|
||||
X-Robots-Tag "noindex, nofollow, noarchive, nositelinkssearchbox, nosnippet, notranslate, noimageindex"
|
||||
|
||||
# enable HSTS
|
||||
# WARNING: Once this value is set, the site must continue to support HTTPS until the expiry time is reached.
|
||||
|
||||
# Strict-Transport-Security max-age=15768000;
|
||||
|
||||
# Remove "Server" header
|
||||
-Server
|
||||
}
|
||||
|
||||
header @api {
|
||||
Access-Control-Allow-Methods "GET, OPTIONS"
|
||||
Access-Control-Allow-Origin "*"
|
||||
}
|
||||
|
||||
route {
|
||||
# Cache policy
|
||||
header Cache-Control "no-cache"
|
||||
header @static Cache-Control "public, max-age=30, stale-while-revalidate=60"
|
||||
header @imageproxy Cache-Control "public, max-age=3600"
|
||||
}
|
||||
|
||||
# SearXNG
|
||||
reverse_proxy localhost:8080
|
||||
@@ -1,6 +1,6 @@
|
||||
# mkdir -pv /data/volumes/searxng/{redis-data,etc-searxng}
|
||||
# pull:: docker compose --env-file ./searxng/env.cfg -f ./searxng/searxng.stack.yml pull
|
||||
# Run:: docker compose --env-file ./searxng/env.cfg -f ./searxng/searxng.stack.yml up -d
|
||||
# pull:: docker compose --env-file ./searxng/env.cfg -f ./searxng/stack.yml pull
|
||||
# Run:: docker compose --env-file ./searxng/env.cfg -f ./searxng/stack.yml up -d
|
||||
|
||||
services:
|
||||
|
||||
Reference in New Issue
Block a user