Sign inSign up

humbertovarona/nginx

By humbertovarona

โ€ขUpdated over 1 year ago

Lightweight image based on Alpine Linux (v3.21), Nginx server v1.26.3-r0 and PHP 8.3 FPM

Image
Networking
Web servers
Operating systems
0

1.3K

humbertovarona/nginx repository overview

โ ๐Ÿš€ Nginx + PHP 8.3 Alpine Container

Docker Alpine License Build NGINX


โ ๐Ÿ“† Summary

A lightweight, secure, and dynamic container image based on Alpine 3.21, featuring:

  • ๐Ÿ”ฅ Nginx with 15+ production modules
  • ๐Ÿ˜ PHP 8.3-FPM with full extension support
  • ๐Ÿ” Automatic HTTPS (via self-signed certs)
  • โš™๏ธ Runtime config via environment variables
  • โค๏ธโ€๐Ÿฉน Integrated healthcheck, time zone sync, and log diagnostics

โ ๐Ÿ“Š Build Info

ParameterValue
Base Imagealpine:3.21
Nginx VersionConfigurable via ARG
PHP VersionPHP 8.3 + extensions

โ ๐Ÿงฐ Environment Variables

VariableDescriptionDefault
TIMEZONESystem timezone (linked to /etc/localtime)UTC
PHP_MEMORY_LIMITPHP memory limit applied via FPM and php.ini512M
NGINX_WORKER_PROCESSESControls Nginx concurrency1
REDIRECT_TO_HTTPSEnables HTTP to HTTPS redirectionno
AUTOCERTAuto-generate self-signed SSL if none is foundno
CERT_WARN_DAYSTriggers a warning log if cert expires in < N days30

โ ๐Ÿ“ Folder Structure (Mounted Volume)

config/
๐Ÿ”ฝ๏ธ www/                # Web content (index.php, etc.)
๐Ÿ”ฝ๏ธ ssl/                # SSL certs: fullchain.pem, privkey.pem
๐Ÿ”ฝ๏ธ data/               # Optional: databases, uploads
๐Ÿ”ฝ๏ธ warnings/           # Auto-generated logs (e.g., cert-warn.log)

โ โค๏ธโ€๐Ÿฉน Healthcheck

Checks:

  • Nginx process
  • PHP-FPM process
  • HTTP/HTTPS reachable (200, 403, 404)
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
  CMD curl -s -L -o /dev/null -w "%{http_code}" http://localhost | grep -qE "200|403|404"

โ ๐Ÿ’ช Docker Usage

โ Run directly
docker run -d --name my-nginx \
  -e TIMEZONE=America/New_York \
  -e PHP_MEMORY_LIMIT=512M \
  -e REDIRECT_TO_HTTPS=yes \
  -e AUTOCERT=yes \
  -p 8080:80 -p 8443:443 \
  -v $(pwd)/config:/config \
  humbertovarona/nginx

Access:

  • http://localhost:8080
  • https://localhost:8443 (self-signed certificate)

โ ๐Ÿงผ docker-compose.yml

version: '3.8'

services:
  web:
    image: humbertovarona/nginx
    container_name: my-nginx
    ports:
      - "8080:80"
      - "8443:443"
    environment:
      TIMEZONE: America/New_York
      PHP_MEMORY_LIMIT: 512M
      REDIRECT_TO_HTTPS: yes
      AUTOCERT: yes
      CERT_WARN_DAYS: 30
    volumes:
      - ./config:/config
    healthcheck:
      test: ["CMD-SHELL", "curl -s -L -o /dev/null -w '%{http_code}' http://localhost | grep -qE '200|403|404'"]
      interval: 30s
      timeout: 5s
      retries: 3

โ ๐Ÿ“œ License

MIT โ€” Use it freely, fork it proudly.


โ ๐Ÿค Contributing

Pull requests, ideas, and bug reports are welcome ๐Ÿ™Œ


โ ๐Ÿ‘จโ€๐Ÿ’ผ Maintainer

HL Varona โ€” @[email protected]โ 

Tag summary

Content type

Image

Digest

sha256:95c640970โ€ฆ

Size

44.4 MB

Last updated

over 1 year ago

docker pull humbertovarona/nginx