A lightweight, rootless-compatible Nginx container based on BoxHarbor's Alpine base image.
363
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.
/configdocker 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:latest
podman 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:latest
version: '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 hostEdit 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 nginx
Mount your certificates and update the configuration:
volumes:
- ./config:/config
- ./certs:/config/ssl:ro
- ./web:/web
Update 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:latest
Edit /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:/web
Ensure PUID/PGID match your host user:
id -u # Get your UID
id -g # Get your GID
Set these in your docker run command or compose file.
Change the host port:
docker run -d -p 9090:8080 ghcr.io/boxharbor/nginx:latest
Check logs:
docker logs nginx
# or
podman logs nginx
Test configuration:
docker exec nginx nginx -t
git 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.
Built with ā¤ļø by the BoxHarbor team
Content type
Image
Digest
sha256:7721b8db9ā¦
Size
9.4 MB
Last updated
11 months ago
docker pull gaetanddr/nginx