A lightweight, rootless-compatible Nginx container based on BoxHarbor's Alpine base image. Perfect for serving static content, reverse proxying, or as a foundation for web applications.
- πͺΆ Lightweight: Alpine-based
- π Rootless Compatible: Works with Podman and Docker rootless
- β‘ High Performance: Optimized Nginx configuration
- π Persistent Config: Store configuration in
/config - π Multi-arch: Supports amd64, arm64, armv7
- π§ Easy Customization: Simple configuration management
docker run -d \
--name nginx \
-p 8080:8080 \
-v $(pwd)/config:/config \
-v $(pwd)/web:/web \
-e PUID=1000 \
-e PGID=1000 \
ghcr.io/boxharbor/nginx:latestpodman run -d \
--name nginx \
-p 8080:8080 \
-v $(pwd)/config:/config:Z \
-v $(pwd)/web:/web:Z \
-e PUID=1000 \
-e PGID=1000 \
ghcr.io/boxharbor/nginx:latestversion: '3.8'
services:
nginx:
image: ghcr.io/boxharbor/nginx:latest
container_name: nginx
ports:
- "8080:8080"
volumes:
- ./config:/config
- ./web:/web
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
restart: unless-stopped| Variable | Default | Description |
|---|---|---|
PUID |
1000 |
User ID for file permissions |
PGID |
1000 |
Group ID for file permissions |
TZ |
UTC |
Timezone |
UMASK |
022 |
File creation mask |
| Path | Description |
|---|---|
/config |
Nginx configuration files |
/web |
Web root directory (default document root) |
| Port | Description |
|---|---|
8080 |
HTTP (non-privileged port for rootless) |
/config/
βββ nginx.conf # Main Nginx configuration
βββ sites-enabled/ # Virtual host configurations
β βββ default.conf # Default site
βββ ssl/ # SSL certificates (if needed)
/web/
βββ index.html # Your web content
On first run, default configuration files are copied to /config:
nginx.conf- Main Nginx configurationsites-enabled/default.conf- Default virtual host
Edit these files to customize your setup!
Create a new file in /config/sites-enabled/:
server {
listen 8080;
server_name example.com;
root /web/example;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}Restart the container to apply changes:
docker restart nginx
# or
podman restart nginxMount your certificates and update the configuration:
volumes:
- ./config:/config
- ./certs:/config/ssl:ro
- ./web:/webUpdate sites-enabled/default.conf:
server {
listen 8443 ssl;
ssl_certificate /config/ssl/cert.pem;
ssl_certificate_key /config/ssl/key.pem;
# ... rest of configuration
}# Place your files in ./web/
mkdir -p ./web
echo "<h1>Hello from BoxHarbor!</h1>" > ./web/index.html
# Run the container
docker run -d -p 8080:8080 -v $(pwd)/web:/web ghcr.io/boxharbor/nginx:latestEdit /config/sites-enabled/default.conf:
server {
listen 8080;
server_name api.example.com;
location / {
proxy_pass http://backend:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}services:
nginx:
image: ghcr.io/boxharbor/nginx:latest
volumes:
- ./config:/config
- ./web:/web
depends_on:
- php-fpm
php-fpm:
image: php:fpm-alpine
volumes:
- ./web:/webEnsure PUID/PGID match your host user:
id -u # Get your UID
id -g # Get your GIDSet these in your docker run command or compose file.
Change the host port:
docker run -d -p 9090:8080 ghcr.io/boxharbor/nginx:latestCheck logs:
docker logs nginx
# or
podman logs nginxTest configuration:
docker exec nginx nginx -tgit clone https://github.com/BoxHarbor/nginx.git
cd nginx
docker build -t boxharbor/nginx:latest .Contributions are welcome! Please read our Contributing Guidelines before submitting PRs.
GPL-3.0 License - see LICENSE file for details.
- π¬ GitHub Issues: Report bugs or request features
- π Base Image: BoxHarbor baseimage-alpine
Built with β€οΈ by the BoxHarbor team