1. The problem I’m having:
- I setup searxng from this github repo - GitHub - searxng/searxng-docker: The docker-compose files for setting up a SearXNG instance with docker. on a raspberrypi v5
- The setup creates a Docker stack with Caddy, searxng, and redis
- Searxng is working, but only via HTTP.
- Expect to be redirected to HTTPS
2. Error messages and/or full log output:
PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.
* Specifying https in a Chrome browser returns (URL = https://192.168.86.249:8080) ERR_CONNECTION_CLOSED. I have not tested with other browsers
* curl 192.168.86.249:8080 returns "Too Many Requests"
* curl -vL output
''' * Trying 192.168.86.249:8080...
* Connected to 192.168.86.249 (192.168.86.249) port 8080 (#0)
> GET / HTTP/1.1
> Host: 192.168.86.249:8080
> User-Agent: curl/7.88.1
> Accept: */*
>
< HTTP/1.1 429 TOO MANY REQUESTS
< Content-Type: text/html; charset=utf-8
< Content-Length: 17
< Server-Timing: total;dur=1.597, render;dur=0
< X-Content-Type-Options: nosniff
< X-Download-Options: noopen
< X-Robots-Tag: noindex, nofollow
< Referrer-Policy: no-referrer
< Connection: close
<
* Closing connection 0
Caddy Logs
INF ts=1733421801.6143177 msg=using config from file file=/etc/caddy/Caddyfile
INF ts=1733421801.6165607 msg=adapted config to JSON adapter=caddyfile
WRN ts=1733421801.6171393 logger=admin msg=admin endpoint disabled
WRN ts=1733421801.6172726 logger=http.auto_https msg=server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server server_name=srv0 http_port=80
INF ts=1733421801.6173203 logger=tls.cache.maintenance msg=started background certificate maintenance cache=0x40007c2500
INF ts=1733421801.6182463 logger=http.log msg=server running name=srv0 protocols=["h1","h2","h3"]
INF ts=1733421801.618409 msg=autosaved config (load with --resume flag) file=/config/caddy/autosave.json
INF ts=1733421801.6184182 msg=serving initial configuration
{"level":"info","ts":1733421801.6265461,"logger":"tls","msg":"storage cleaning happened too recently; skipping for now","storage":"FileStorage:/data/caddy","instance":"19ed4355-3bd1-45bc-b2a0-30fcfe2bf5e2","try_again":1733508201.6265445,"try_again_in":86399.999999667}
INF ts=1733421801.6266148 logger=tls msg=finished cleaning storage units
3. Caddy version:
v2.8.4 h1:q3pe0wpBj1OcHFZ3n/1nl4V4bxBrYoSoab7rL9BMYNk=
4. How I installed and ran Caddy:
a. System environment:
- Raspberry Pi 5
- ARM processor
- Docker
- Docker version 20.10.24+dfsg1, build 297e128
- in a stack with searxng
- docker network = searxng-docker
b. Command:
docker compose up -d
c. Service/unit/compose file:
services:
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:80}
- 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:
- "8080: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:
caddy-data:
caddy-config:
valkey-data2:
d. My complete Caddy config:
{
admin off
}
{$SEARXNG_HOSTNAME} {
log {
output discard
}
tls {$SEARXNG_TLS}
@api {
path /config
path /healthz
path /stats/errors
path /stats/checker
}
@static {
path /static/*
}
@notstatic {
not path /static/*
}
@imageproxy {
path /image_proxy
}
@notimageproxy {
not path /image_proxy
}
header {
# Enable HTTP Strict Transport Security (HSTS) to force clients to always connect via HTTPS
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
# Enable cross-site filter (XSS) and tell browser to block detected attacks
X-XSS-Protection "1; mode=block"
# Prevent some browsers from MIME-sniffing a response away from the declared Content-Type
X-Content-Type-Options "nosniff"
# Disable some features
Permissions-Policy "accelerometer=(),ambient-light-sensor=(),autoplay=(),camera=(),encrypted-media=(),focus-without-user-activation=(),geolocation=(),gyroscope=(),magnetometer=(),microphone=(),midi=(),payment=(),picture-in-picture=(),speaker=(),sync-xhr=(),usb=(),vr=()"
# Disable some features (legacy)
Feature-Policy "accelerometer 'none';ambient-light-sensor 'none'; autoplay 'none';camera 'none';encrypted-media 'none';focus-without-user-activation 'none'; geolocation 'none';gyroscope 'none';magnetometer 'none';microphone 'none';midi 'none';payment 'none';picture-in-picture 'none'; speaker 'none';sync-xhr 'none';usb 'none';vr 'none'"
# Referer
Referrer-Policy "no-referrer"
# X-Robots-Tag
X-Robots-Tag "noindex, noarchive, nofollow"
# Remove Server header
-Server
}
header @api {
Access-Control-Allow-Methods "GET, OPTIONS"
Access-Control-Allow-Origin "*"
}
# Cache
header @static {
# Cache
Cache-Control "public, max-age=31536000"
defer
}
header @notstatic {
# No Cache
Cache-Control "no-cache, no-store"
Pragma "no-cache"
}
# CSP (see http://content-security-policy.com/ )
header @imageproxy {
Content-Security-Policy "default-src 'none'; img-src 'self' data:"
}
header @notimageproxy {
Content-Security-Policy "upgrade-insecure-requests; default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; form-action 'self' https://github.com/searxng/searxng/issues/new; font-src 'self'; frame-ancestors 'self'; base-uri 'self'; connect-src 'self' https://overpass-api.de; img-src 'self' data: https://*.tile.openstreetmap.org; frame-src https://www.youtube-nocookie.com https://player.vimeo.com https://www.dailymotion.com https://www.deezer.com https://www.mixcloud.com https://w.soundcloud.com https://embed.spotify.com"
}
# SearXNG
handle {
encode zstd gzip
reverse_proxy localhost:8080 {
header_up X-Forwarded-Port {http.request.port}
#header_up X-Forwarded-Proto {http.request.scheme}
header_up X-Real-IP {remote_host}
}
}
}