mirror of
https://github.com/nickyeoman/docker-compose-cookbooks.git
synced 2026-12-06 12:28:50 +00:00
nginx-proxy-manager: standard README order, headscale-ui placeholder gotcha, rename compose.yaml
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,58 +1,62 @@
|
||||
# Nginx Proxy Manager
|
||||
|
||||
Remember, if dockhand is using a domain name, this will have to be set up first.
|
||||
|
||||
I run one instance of Nginx Proxy Manager (NPM) on each host.
|
||||
|
||||
## Overview
|
||||
|
||||
This Docker Compose configuration sets up the Reverse Proxy application using a Docker container.
|
||||
Nginx Proxy Manager (NPM) is the reverse proxy in front of every other stack in this repo. I run one instance on each host.
|
||||
|
||||
- App: [Proxy Manager on Docker Hub](https://hub.docker.com/r/jc21/nginx-proxy-manager)
|
||||
- Official Site: [Nginx Proxy Manager](https://nginxproxymanager.com/)
|
||||
- [Docker tags](https://hub.docker.com/r/jc21/nginx-proxy-manager/tags)
|
||||
- Expose ports: 80, 81, 443
|
||||
Unlike the other stacks, NPM is normally run with `docker run`, not through Dockhand. If Dockhand is reached by a domain name (FQDN), it can't be reached while the reverse proxy is down, so NPM has to start independently of Dockhand. Set NPM up first.
|
||||
|
||||
## Default Login
|
||||
## Project Details
|
||||
|
||||
* Email: admin@example.com
|
||||
* Password: changeme
|
||||
- **Project Repository:** [GitHub](https://github.com/NginxProxyManager/nginx-proxy-manager)
|
||||
- **Container Image:** [Docker Hub](https://hub.docker.com/r/jc21/nginx-proxy-manager) ([tags](https://hub.docker.com/r/jc21/nginx-proxy-manager/tags))
|
||||
- **Documentation:** [nginxproxymanager.com](https://nginxproxymanager.com/)
|
||||
- **Exposed Ports:** `80`, `443` (HTTP/HTTPS), `81` (admin UI)
|
||||
|
||||
## Create Network
|
||||
## Getting Started
|
||||
|
||||
The first thing you want to do is create the network:
|
||||
1. Create the shared network (once per host): `docker network create proxy`
|
||||
2. Create the volume directories (see [Volume Notes](#volume-notes))
|
||||
3. Start the container with the [Docker Run](#docker-run) command
|
||||
4. Open http://localhost:81 and log in with the default credentials, then change them right away:
|
||||
* Email: `admin@example.com`
|
||||
* Password: `changeme`
|
||||
|
||||
```bash
|
||||
docker network create proxy
|
||||
```
|
||||
## Environment Variable Notes
|
||||
|
||||
## Expose Ports
|
||||
These apply to the compose file (`sample.env`). The `docker run` command hardcodes the defaults.
|
||||
|
||||
80 and 443 must be exposed, but you could proxy to 81 for the admin interface.
|
||||
VOL_PATH – base path for data and letsencrypt volumes (default /data)
|
||||
LOG_PATH – where NPM logs are written (default /var/log/containers/nginx-proxy-manager)
|
||||
PROXY_IMAGE – image and tag to run
|
||||
|
||||
### Create volumes
|
||||
## Volume Notes
|
||||
|
||||
Assuming default sample.env is used:
|
||||
/data/nginx-proxy-manager/data – NPM database and config (back this up)
|
||||
/data/nginx-proxy-manager/letsencrypt – certificates (back this up)
|
||||
/var/log/containers/nginx-proxy-manager – access/error logs
|
||||
|
||||
```bash
|
||||
mkdir -p /data/nginx-proxy-manager/data /data/nginx-proxy-manager/letsencrypt /var/log/containers/nginx-proxy-manager
|
||||
```
|
||||
|
||||
## Logs
|
||||
NPM writes logs under `/data/logs` inside the container. They're mounted outside of `VOL_PATH` via `LOG_PATH` so they aren't backed up with the rest of the data. If you'd rather back up/sync logs too, remove the logs volume.
|
||||
|
||||
Nginx Proxy Manager writes access/error logs under `/data/logs`, which is mounted outside of `VOL_PATH`. Since logs shouldn't be backed up with the rest of the data, they're mounted separately via `LOG_PATH`, which defaults to `/var/log/containers/nginx-proxy-manager`. If you'd rather back up/sync logs with the rest of the data, just remove the logs volume.
|
||||
## Network Notes
|
||||
|
||||
NPM joins the `proxy` network, which every other stack attaches to as an external network. Create it once per host:
|
||||
|
||||
```bash
|
||||
mkdir -p /var/log/containers/nginx-proxy-manager
|
||||
docker network create proxy
|
||||
```
|
||||
|
||||
## Equivalent docker run command
|
||||
Ports 80 and 443 must be exposed. Port 81 (admin UI) can be exposed or proxied through NPM itself.
|
||||
|
||||
## Docker Run
|
||||
|
||||
This is the usual way to run NPM.
|
||||
|
||||
```bash
|
||||
mkdir -p /data/nginx-proxy-manager/data /data/nginx-proxy-manager/letsencrypt /var/log/containers/nginx-proxy-manager
|
||||
|
||||
docker network create proxy
|
||||
|
||||
docker run -d \
|
||||
--name nginx-proxy-manager \
|
||||
--restart unless-stopped \
|
||||
@@ -68,22 +72,15 @@ docker run -d \
|
||||
jc21/nginx-proxy-manager:latest
|
||||
```
|
||||
|
||||
## Upgrade (and backup)
|
||||
### Upgrade (and backup)
|
||||
|
||||
Back up the data volume with restic before upgrading, so you can restore it if the new version doesn't come up cleanly. Logs aren't included since they're not needed for a restore.
|
||||
Back up the data with restic before upgrading so you can restore it if the new version doesn't come up cleanly. Logs aren't needed for a restore.
|
||||
|
||||
```bash
|
||||
restic backup /data/nginx-proxy-manager
|
||||
```
|
||||
|
||||
Once the backup completes, pull the new image and recreate the container:
|
||||
|
||||
```bash
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
Or, if you're running the `docker run` version instead of compose:
|
||||
Then pull the new image and recreate the container:
|
||||
|
||||
```bash
|
||||
docker pull jc21/nginx-proxy-manager:latest
|
||||
@@ -104,4 +101,50 @@ docker run -d \
|
||||
jc21/nginx-proxy-manager:latest
|
||||
```
|
||||
|
||||
If you're using the compose file instead: `docker compose pull && docker compose up -d`.
|
||||
|
||||
If something goes wrong, restore the snapshot with `restic restore latest --target /` (or `restic snapshots` to pick an earlier one) and start the old container again.
|
||||
|
||||
## Additional Notes / Gotchas
|
||||
|
||||
### Placeholder `headscale-ui` on dev/slave instances
|
||||
|
||||
If NPM config is synced from production to dev/slave instances, the proxy host for `headscale-ui` still exists there. NPM checks that the upstream container resolves, and fails if `headscale-ui` isn't on the network. On non-production hosts, run a tiny nginx placeholder that answers with a 503.
|
||||
|
||||
1. Create `compose.yaml`:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
headscale-ui:
|
||||
image: nginx:alpine
|
||||
container_name: headscale-ui
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./default.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
networks:
|
||||
- proxy
|
||||
|
||||
networks:
|
||||
proxy:
|
||||
external: true
|
||||
```
|
||||
|
||||
2. Create `default.conf` next to it:
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
location / {
|
||||
default_type text/plain;
|
||||
return 503 "Headscale UI is not available on this node.\n";
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
3. Start it with `docker compose up -d`.
|
||||
|
||||
## Dockhand Stack, Deploy from Git
|
||||
|
||||
Not recommended. NPM isn't deployed through Dockhand, because Dockhand can't be reached by its FQDN while the reverse proxy is down. Use the [Docker Run](#docker-run) command instead. `compose.yaml` is kept for reference and for hosts where Dockhand is reached by IP.
|
||||
|
||||
Reference in New Issue
Block a user