proxy/README.md

110 lines
3.3 KiB
Markdown
Raw Permalink Normal View History

2025-06-18 17:16:13 +00:00
# Nginx + Certbot + ACMEDNS Proxy Stack
2025-06-18 17:32:10 +00:00
*[Full documentation → docs site](https://youruser.github.io/proxy-stack/)*
Simple reverseproxy setup packaged in a single Docker image. Nginx handles HTTP/S and TCP/UDP streams; Certbot issues and renews Lets Encrypt certificates via ACMEDNS (DNS01). packaged in a single Docker image. Nginx handles HTTP/S and TCP/UDP streams; Certbot issues and renews Lets Encrypt certificates via ACMEDNS (DNS01).
2025-06-18 17:16:13 +00:00
---
2025-06-18 17:32:10 +00:00
## Whats in this repo
2025-06-18 17:16:13 +00:00
2025-06-18 17:32:10 +00:00
| Path / file | Purpose |
| ------------------- | ---------------------------------------------------- |
| `dockerfile.debian` | Builds the image (Debian slim + Nginx + Certbot) |
| `compose.yml` | Oneservice Docker Compose file |
| `acme-dns-auth.py` | Helper script called by Certbot for DNS01 |
| `certbot-runner` | Convenience wrapper to open a shell in the image |
| `conf.d/` | **Not tracked** drop HTTP/S vhost configs here |
| `stream.d/` | **Not tracked** drop stream (TCP/UDP) configs here |
| `letsencrypt/` | Empty volume for keys/certs (gitignored) |
| `work/` | Certbot cache (gitignored) |
2025-06-18 17:16:13 +00:00
---
2025-06-18 17:32:10 +00:00
## Prerequisites
2025-06-18 17:16:13 +00:00
2025-06-18 17:32:10 +00:00
* Docker 24 or later
* Docker Compose v2 (or Docker Swarm if you prefer)
2025-06-18 17:16:13 +00:00
---
2025-06-18 17:32:10 +00:00
## Quick start (single node)
2025-06-18 17:16:13 +00:00
```bash
2025-06-18 17:32:10 +00:00
# clone
2025-06-18 17:16:13 +00:00
$ git clone https://github.com/youruser/proxy-stack.git
$ cd proxy-stack
2025-06-18 17:32:10 +00:00
# create runtime dirs so volume binds dont fail
$ mkdir -p letsencrypt work
2025-06-18 17:16:13 +00:00
2025-06-18 17:32:10 +00:00
# build the image (or pull one you published)
$ docker build -t proxy:latest -f dockerfile.debian .
2025-06-18 17:16:13 +00:00
2025-06-18 17:32:10 +00:00
# start Nginx + Certbot
$ IMAGE_NAME=proxy:latest docker compose up -d
2025-06-18 17:16:13 +00:00
2025-06-18 17:32:10 +00:00
# obtain an initial certificate (DNS01)
$ DOMAIN=example.com ./certbot-runner
# follow the prompts → add the TXT/CNAME → press <enter>
2025-06-18 17:16:13 +00:00
```
2025-06-18 17:32:10 +00:00
When certificates renew, Certbot reloads Nginx automatically.
2025-06-18 17:16:13 +00:00
---
2025-06-18 17:32:10 +00:00
## Certificates (DNS01 quick guide)
2025-06-18 17:16:13 +00:00
2025-06-18 17:32:10 +00:00
```bash
# Run inside the container (root)
certbot certonly \
--manual \
--manual-auth-hook /etc/letsencrypt/acme-dns-auth.py \
--preferred-challenges dns \
--debug-challenges \
-d '*.your-domain' -d your-domain
```
2025-06-18 17:16:13 +00:00
2025-06-18 17:32:10 +00:00
1. The hook registers (or reuses) an **acmedns** account and prints a CNAME like:
2025-06-18 17:16:13 +00:00
2025-06-18 17:32:10 +00:00
```text
_acme-challenge.your-domain. CNAME 8a1b12c3-...acme-dns.io.
```
2025-06-18 17:16:13 +00:00
2025-06-18 17:32:10 +00:00
2. Create that CNAME in *your* authoritative DNS zone (or update if it exists).
3. Press **<Enter>** Certbot validates, stores the certs under
`/etc/letsencrypt/live/your-domain/`, and reloads Nginx.
2025-06-18 17:16:13 +00:00
2025-06-18 17:32:10 +00:00
Thats it future renewals happen automatically (`certbot renew`).
2025-06-18 17:16:13 +00:00
---
2025-06-18 17:32:10 +00:00
## Directory rules
2025-06-18 17:16:13 +00:00
2025-06-18 17:32:10 +00:00
Everything that contains private keys or runtime state is ignored by Git:
2025-06-18 17:16:13 +00:00
2025-06-18 17:32:10 +00:00
```text
letsencrypt/ # keys, certs, renewal configs
work/ # Certbot cache
conf.d/ # your real vhosts ignored
stream.d/ # your real stream configs ignored
```
2025-06-18 17:16:13 +00:00
2025-06-18 17:32:10 +00:00
Provide examples by naming them `*.example.conf`; those are the only files tracked inside `conf.d/` and `stream.d/`.
2025-06-18 17:16:13 +00:00
2025-06-18 17:32:10 +00:00
---
## Updating
2025-06-18 17:16:13 +00:00
2025-06-18 17:32:10 +00:00
```bash
# Rebuild image when Nginx or Certbot update
$ docker build -t proxy:latest . && docker compose up -d
```
2025-06-18 17:16:13 +00:00
---
2025-06-18 17:32:10 +00:00
## License
2025-06-18 17:16:13 +00:00
2025-06-18 17:32:10 +00:00
Released under **GPL2.0** see `LICENSE` for full text.
2025-06-18 17:16:13 +00:00