Caddyfile•2.22 kB
# Caddyfile for SearXNG reverse proxy
# This configuration provides HTTPS termination and proxies requests to SearXNG
{$SEARXNG_HOSTNAME:localhost} {
@api {
path /search
query format=json*
}
@static {
path /static/*
}
# Enable automatic HTTPS
tls {$SEARXNG_TLS:internal}
# Enable compression
encode gzip
# Security headers
header {
# Remove server identification
-Server
# Security headers
X-Content-Type-Options nosniff
X-Frame-Options DENY
X-XSS-Protection "1; mode=block"
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self'; connect-src 'self'; media-src 'self'; object-src 'none'; child-src 'self'; frame-src 'self'; worker-src 'self'; frame-ancestors 'none'; form-action 'self'; base-uri 'self'"
Referrer-Policy "no-referrer"
# CORS headers for API access
Access-Control-Allow-Origin "*"
Access-Control-Allow-Methods "GET, POST, OPTIONS"
Access-Control-Allow-Headers "Content-Type, Authorization, X-Requested-With"
}
# Handle preflight requests
@options {
method OPTIONS
}
respond @options 204
# Proxy API requests with special handling
handle @api {
reverse_proxy searxng:8080 {
header_down Access-Control-Allow-Origin "*"
header_down Access-Control-Allow-Methods "GET, POST, OPTIONS"
header_down Access-Control-Allow-Headers "Content-Type, Authorization, X-Requested-With"
}
}
# Proxy static files
handle @static {
reverse_proxy searxng:8080
}
# Proxy all other requests to SearXNG
handle {
reverse_proxy searxng:8080
}
# Logging
log {
output file /data/access.log {
roll_size 10mb
roll_keep 10
}
format json
level INFO
}
}
# Health check endpoint (optional)
:9090 {
respond /health 200
respond /ready 200
}