HUB
Sign inSign up

ricariel/nginx

By ricariel

•Updated 10 days ago

Nginx generic docker module

Image
0

50K+

ricariel/nginx repository overview

⁠nginx-docker

An nginx⁠ image for serving static websites, based on the official nginx:stable image. It ships a hardened default server block and can pull the site content at container start from a Git repository or a ZIP archive.

⁠Features

  • Hardened defaults: security headers, server_tokens off, hidden dotfiles (except .well-known), and a security.txt redirect are preconfigured.
  • Content on startup: the site is fetched at runtime from a Git repository (SITE_REPO) or a ZIP archive (SITE_ARCHIVE) — no rebuild for a content change.
  • Static-site friendly: extensionless URLs resolve via try_files, 404.html is wired to the error page, and assets/fonts get a 30-day cache lifetime.
  • Compression: gzip is on for text, JSON, JavaScript, XML and SVG.

⁠Quickstart

Serve content from a directory on the host:

docker run -d --name web \
  -p 8080:80 \
  -v /path/to/site:/usr/share/nginx/html:ro \
  nginx-docker

Serve content cloned from a Git repository at startup:

docker run -d --name web \
  -p 8080:80 \
  -e SITE_REPO=https://git.example.com/user/site.git \
  -e SITE_BRANCH=main \
  nginx-docker

⁠Configuration

⁠Environment Variables
VariablePurpose
SITE_REPOGit URL cloned into /usr/share/nginx/html at startup. The .git directory is removed afterwards.
SITE_BRANCHBranch to check out after cloning. Only evaluated together with SITE_REPO.
SITE_ARCHIVEURL of a ZIP archive downloaded and unpacked into /usr/share/nginx/html.

Both SITE_REPO and SITE_ARCHIVE replace the existing document root. If neither is set, the entrypoint leaves the image content untouched — mount your own volume in that case.

SITE_ARCHIVE is evaluated after SITE_REPO; setting both means the archive wins.

⁠Server Block

The default virtual host listens on port 80 (IPv4 and IPv6) and serves /usr/share/nginx/html:

SettingValue
Index fileindex.html
Error page/404.html
client_max_body_size16M
Asset/font cachingexpires 30d
CORS on fonts and SVGAccess-Control-Allow-Origin: *

Response headers set on every request:

  • X-XSS-Protection: 1; mode=block
  • X-Content-Type-Options: nosniff
  • Referrer-Policy: no-referrer-when-downgrade
  • Content-Security-Policy (self plus inline styles/scripts, frame-ancestors 'self')
  • Permissions-Policy: interest-cohort=()

Adjust these by mounting your own file over /etc/nginx/conf.d/default.conf, or add further server blocks into /etc/nginx/conf.d/.

⁠Startup Sequence

The image builds on the official nginx entrypoint, which runs everything in /docker-entrypoint.d/ in lexicographic order. This image adds one script:

ScriptPurpose
90-get-page.shFetches the site content from SITE_REPO or SITE_ARCHIVE

Because the prefix is 90, it runs after the upstream template and configuration steps and just before nginx starts.

⁠Building

docker build -t nginx-docker .

The build runs apt-get upgrade on top of nginx:stable, so the weekly rebuild picks up Debian security fixes even before the upstream image is refreshed.

TLS termination is deliberately not part of this image — it is meant to run behind a reverse proxy or ingress controller that handles certificates.

⁠Contributing

This project uses pre-commit for style and quality checks, Conventional Commits for the history, and Renovate for dependency updates.

⁠Security dashboard

The issue "Security Dashboard" lists the open CVE findings in the image built here, for every environment that runs it, with checkboxes: open an issue, ignore, snooze, request a check, start a rebuild. The weekly CVE scan writes the rows; the workflow .forgejo/workflows/security-dashboard.yaml (pyrox/actions/security-dashboard) executes a ticked box right away. It needs the secrets SECURITY_DASHBOARD_TOKEN and SECURITY_DASHBOARD_KEY.

⁠License

MIT — see LICENSE⁠.

Tag summary

Content type

Image

Digest

sha256:1f30d9dc6…

Size

89.8 MB

Last updated

10 days ago

docker pull ricariel/nginx