Compare commits

...

22 Commits

Author SHA1 Message Date
Ivan Gabaldon
2138c5d13d Deprecation notice
Templates moved to https://github.com/searxng/searxng/tree/master/container
Documentation moved to https://docs.searxng.org/admin/installation-docker.html
2026-03-28 20:09:29 +01:00
ArnoldCordewiner
0c7875a429 Remove the "version" attribute (#429) 2025-09-21 21:40:14 +02:00
Markus Heiser
c33905f78a Merge pull request #425 from searxng/revert-424-mod-caddy-csp
Revert "[mod] caddy: update csp"
2025-08-21 13:24:33 +02:00
Markus Heiser
cf2444a5ef Revert "[mod] caddy: update csp (#424)"
This reverts commit bc0cfa3d28.
2025-08-21 13:23:57 +02:00
Ivan Gabaldon
bc0cfa3d28 [mod] caddy: update csp (#424)
Since https://github.com/searxng/searxng/pull/5073 we add a script directly to the [`base.html`](https://github.com/searxng/searxng/blob/master/searx/templates/simple/base.html), we need `'unsafe-inline'`.
2025-08-18 21:59:55 +02:00
echo r"0xX4H" | rev
d9357aca09 [enh] add HSTS header (#419) 2025-08-15 16:31:02 +02:00
Ivan Gabaldon
649d7509c9 [fix] container: move references (#417) 2025-08-07 12:37:32 +02:00
Ivan Gabaldon
8de6ea65ab [fix] container: remove static hashing (#410)
* [fix] container: remove static hashing

Allows browser cache heuristics to properly work.

Related https://github.com/searxng/searxng/pull/5006
Closes https://github.com/searxng/searxng-docker/issues/409

* [fix] container: don't revalidate at every request

As Granian no longer handles static files directly, the whole process goes through Flask, which apart from being slow, is resource intensive, even to serve HTTP 304 responses.
2025-07-19 10:19:17 +02:00
Ivan Gabaldon
b0107a0801 [fix] container: dangling Dockerfile reference (#407)
Closes https://github.com/searxng/searxng-docker/issues/403
2025-07-10 21:30:05 +02:00
Ivan Gabaldon
8b75609524 [mod] container: replace uWSGI with Granian (#395)
To sync with https://github.com/searxng/searxng/pull/4820
2025-07-04 14:35:43 +02:00
Ivan Gabaldon
fc51db2367 [fix] container: missing data volume (#399)
Synced from a76ccba9c5/container/base.yml (L54)
2025-06-28 08:59:38 +02:00
ItsNiceCraft
8fe0b98ced docs: remove security cap note (#398) 2025-06-23 21:47:34 +02:00
Ivan Gabaldon
8c006d702f [fix] caddy: revise csp header (#397)
Relaxes some policies, there are obsolete options that are not currently in use that have been removed as well.

Closes https://github.com/searxng/searxng-docker/issues/371
Closes https://github.com/searxng/searxng-docker/issues/177
Closes https://github.com/searxng/searxng/issues/4304
2025-06-14 16:17:08 +02:00
Ivan Gabaldon
6022367de4 [mod] caddy: trusted proxies support (#396)
Early preparation for https://github.com/searxng/searxng/pull/4911
2025-06-14 15:21:40 +02:00
Émilien (perso)
6299a68922 chore: deactivate limiter by default for easier setup (#384) 2025-05-25 18:24:08 +02:00
Ivan Gabaldon
31acd45ec2 [fix] remove security cap
Fixes 749de829d5bad6a05ebe1a733a6bd942c1a386ec
2025-05-20 14:39:21 +02:00
Émilien (perso)
21bca5efa8 fix: layout about mac sed command 2025-03-06 13:32:12 +01:00
Alex Wall
4aa1d14878 Update README.md (#352)
Added Mac syntax on sed command.
2025-03-05 21:15:13 +01:00
Ivan Gabaldon
9adeb8a6f2 revert setting env on Caddyfile (#341) 2025-02-15 21:21:43 +01:00
Ivan Gabaldon
5fc00a3285 Rework Caddyfile (#255)
* rework Caddyfile

* fix missing "public" directive

* features cleanup

Since this header is attached to each outgoing request the overall size is slightly increased by 300 bytes, we don't care if the site is allowed to play media in the background, so with the vast majority of features that have been added (and those that were already present)

* restore encode directive

Caddyserver actually did passthrough the precompressed resources served by uWSGI (Oops)

* merge upstream changes

* fix typo

---------

Co-authored-by: Émilien (perso) <4016501+unixfox@users.noreply.github.com>
2025-02-14 10:27:41 +01:00
(root@itachi)-[~]
a899b72a50 Updated version of "Start SearXNG with systemd"
* Update: grammatical correctness in README.md

* Update:  grammatical accuracy on README.md

* Update: enhance readability and include proper syntax highlighting for the commands under "Start SearXNG with systemd" in README.md

Update: enhance readability and include proper syntax highlighting for the commands under "Start SearXNG with systemd" in README.md

Update README.md

Update README.md

Update README.md

Update: enhance readability and included proper syntax highlighting for the commands under "Start SearXNG with systemd" in README.md

Update: Space Fix!

Update: Space Fixing in cp command
2025-01-03 15:15:03 +01:00
(root@itachi)-[~]
271ba86644 Update: grammatical correctness in README.md (#315)
* Update: grammatical correctness in README.md

* Update:  grammatical accuracy on README.md
2025-01-03 10:33:54 +01:00
8 changed files with 7 additions and 335 deletions

14
.env
View File

@@ -1,14 +0,0 @@
# By default listen on https://localhost
# To change this:
# * uncomment SEARXNG_HOSTNAME, and replace <host> by the SearXNG hostname
# * uncomment LETSENCRYPT_EMAIL, and replace <email> by your email (require to create a Let's Encrypt certificate)
# SEARXNG_HOSTNAME=<host>
# LETSENCRYPT_EMAIL=<email>
# Optional:
# If you run a very small or a very large instance, you might want to change the amount of used uwsgi workers and threads per worker
# More workers (= processes) means that more search requests can be handled at the same time, but it also causes more resource usage
# SEARXNG_UWSGI_WORKERS=4
# SEARXNG_UWSGI_THREADS=4

6
.gitignore vendored
View File

@@ -1,6 +0,0 @@
*~
searxng-docker.service
caddy
srv
searxng/uwsgi.ini

View File

@@ -1,99 +0,0 @@
{
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}
}
}
}

111
README.md
View File

@@ -1,105 +1,8 @@
# searxng-docker > [!WARNING]
> *searxng-docker* repository is superseded.
>
> For [**NEW installations**](https://docs.searxng.org/admin/installation-docker.html#compose-instancing)
>
> For [**EXISTING installations**](https://docs.searxng.org/admin/installation-docker.html#migrate-from-searxng-docker)
Create a new SearXNG instance in five minutes using Docker Continue to [*searxng-docker*](https://github.com/searxng/searxng-docker/tree/0c7875a42942e916ab39b171d69cab7d170ddb60) (deprecated)
## What is included ?
| Name | Description | Docker image | Dockerfile |
| -- | -- | -- | -- |
| [Caddy](https://github.com/caddyserver/caddy) | Reverse proxy (create a LetsEncrypt certificate automatically) | [docker.io/library/caddy:2-alpine](https://hub.docker.com/_/caddy) | [Dockerfile](https://github.com/caddyserver/caddy-docker/blob/master/Dockerfile.tmpl) |
| [SearXNG](https://github.com/searxng/searxng) | SearXNG by itself | [docker.io/searxng/searxng:latest](https://hub.docker.com/r/searxng/searxng) | [Dockerfile](https://github.com/searxng/searxng/blob/master/Dockerfile) |
| [Valkey](https://github.com/valkey-io/valkey) | In-memory database | [docker.io/valkey/valkey:8-alpine](https://hub.docker.com/r/valkey/valkey) | [Dockerfile](https://github.com/valkey-io/valkey-container/blob/mainline/Dockerfile.template) |
## How to use it
There are two ways to host SearXNG. The first one doesn't require any prior knowledge about self-hosting and thus is recommended for beginners. It includes caddy as a reverse proxy and automatically deals with the TLS certificates for you. The second one is recommended for more advanced users that already have their own reverse proxy (e.g. Nginx, HAProxy, ...) and probably some other services running on their machine. The first few steps are the same for both installation methods however.
1. [Install docker](https://docs.docker.com/install/)
2. Get searxng-docker
```sh
cd /usr/local
git clone https://github.com/searxng/searxng-docker.git
cd searxng-docker
```
3. Edit the [.env](https://github.com/searxng/searxng-docker/blob/master/.env) file to set the hostname and an email
4. Generate the secret key `sed -i "s|ultrasecretkey|$(openssl rand -hex 32)|g" searxng/settings.yml`
5. Edit [searxng/settings.yml](https://github.com/searxng/searxng-docker/blob/master/searxng/settings.yml) according to your needs
> [!NOTE]
> On the first run, you must remove `cap_drop: - ALL` from the `docker-compose.yaml` file for the `searxng` service to successfully create `/etc/searxng/uwsgi.ini`. This is necessary because the `cap_drop: - ALL` directive removes all capabilities, including those required for the creation of the `uwsgi.ini` file. After the first run, you should re-add `cap_drop: - ALL` to the `docker-compose.yaml` file for security reasons.
> [!NOTE]
> Windows users can use the following powershell script to generate the secret key:
> ```powershell
> $randomBytes = New-Object byte[] 32
> (New-Object Security.Cryptography.RNGCryptoServiceProvider).GetBytes($randomBytes)
> $secretKey = -join ($randomBytes | ForEach-Object { "{0:x2}" -f $_ })
> (Get-Content searxng/settings.yml) -replace 'ultrasecretkey', $secretKey | Set-Content searxng/settings.yml
> ```
### Method 1: With Caddy included (recommended for beginners)
6. Run SearXNG in the background: `docker compose up -d`
### Method 2: Bring your own reverse proxy (experienced users)
6. Remove the caddy related parts in `docker-compose.yaml` such as the caddy service and its volumes.
7. Point your reverse proxy to the port set for the `searxng` service in `docker-compose.yml` (8080 by default).
8. Generate and configure the required TLS certificates with the reverse proxy of your choice.
9. Run SearXNG in the background: `docker compose up -d`
> [!NOTE]
> You can change the port `searxng` listens on inside the docker container (e.g. if you want to operate in `host` network mode) with the `BIND_ADDRESS` environment variable (defaults to `0.0.0.0:8080`). The environment variable can be set directly inside `docker-compose.yaml`.
## Troubleshooting - How to access the logs
To access the logs from all the containers use: `docker compose logs -f`.
To access the logs of one specific container:
- Caddy: `docker compose logs -f caddy`
- SearXNG: `docker compose logs -f searxng`
- Valkey: `docker compose logs -f redis`
### Start SearXNG with systemd
You can skip this step if you don't use systemd.
- ```cp searxng-docker.service.template searxng-docker.service```
- edit the content of ```WorkingDirectory``` in the ```searxng-docker.service``` file (only if the installation path is different from /usr/local/searxng-docker)
- Install the systemd unit:
```sh
systemctl enable $(pwd)/searxng-docker.service
systemctl start searxng-docker.service
```
## Note on the image proxy feature
The SearXNG image proxy is activated by default.
The default [Content-Security-Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy) allow the browser to access to ```${SEARXNG_HOSTNAME}``` and ```https://*.tile.openstreetmap.org;```.
If some users want to disable the image proxy, you have to modify [./Caddyfile](https://github.com/searxng/searxng-docker/blob/master/Caddyfile). Replace the ```img-src 'self' data: https://*.tile.openstreetmap.org;``` by ```img-src * data:;```.
## Multi Architecture Docker images
Supported architecture:
- amd64
- arm64
- arm/v7
## How to update ?
To update the SearXNG stack:
```sh
git pull
docker compose pull
docker compose up -d
```
Or the old way (with the old docker-compose version):
```sh
git pull
docker-compose pull
docker-compose up -d
```

View File

@@ -1,79 +0,0 @@
version: "3.7"
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:
- "127.0.0.1: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:

View File

@@ -1,16 +0,0 @@
[Unit]
Description=SearXNG service
Requires=docker.service
After=docker.service
[Service]
Restart=on-failure
Environment=SEARXNG_DOCKERCOMPOSEFILE=docker-compose.yaml
WorkingDirectory=/usr/local/searxng-docker
ExecStart=/usr/local/bin/docker compose -f ${SEARXNG_DOCKERCOMPOSEFILE} up --remove-orphans
ExecStop=/usr/local/bin/docker compose -f ${SEARXNG_DOCKERCOMPOSEFILE} down
[Install]
WantedBy=multi-user.target

View File

@@ -1,6 +0,0 @@
# This configuration file updates the default configuration file
# See https://github.com/searxng/searxng/blob/master/searx/limiter.toml
[botdetection.ip_limit]
# activate link_token method in the ip_limit method
link_token = true

View File

@@ -1,11 +0,0 @@
# see https://docs.searxng.org/admin/settings/settings.html#settings-use-default-settings
use_default_settings: true
server:
# base_url is defined in the SEARXNG_BASE_URL environment variable, see .env and docker-compose.yml
secret_key: "ultrasecretkey" # change this!
limiter: true # can be disabled for a private instance
image_proxy: true
ui:
static_use_hash: true
redis:
url: redis://redis:6379/0