fix
This commit is contained in:
179
README.md
179
README.md
@@ -1,130 +1,117 @@
|
||||
# Local DNS Services with Docker
|
||||
# Локальная сеть с доменами `.mikan` и HTTPS
|
||||
|
||||
This project provides a local development infrastructure with automatic DNS resolution for custom domains (e.g., `.mikan` or `.local`) and valid HTTPS certificates.
|
||||
Система для запуска сервисов в Docker с автоматическим HTTPS, локальными доменами (`service.mikan`, `service.local`) и возможностью расширения (Tailscale, публичные домены).
|
||||
|
||||
## Features
|
||||
## Требования
|
||||
|
||||
- Automatic DNS resolution for `*.yourdomain` and `*.yourdomain.local`
|
||||
- Valid HTTPS certificates for local domains using `mkcert`
|
||||
- Easy service deployment with `VIRTUAL_HOST` environment variables
|
||||
- Ready for future expansion: public domains, Let's Encrypt, Tailscale
|
||||
- Single-command service creation
|
||||
- Docker + Docker Compose
|
||||
- `mkcert` — [инструкция по установке](https://github.com/FiloSottile/mkcert#installation)
|
||||
- `bash`, `coreutils`
|
||||
|
||||
## Requirements
|
||||
## Быстрый старт
|
||||
|
||||
- Docker and Docker Compose
|
||||
- `mkcert` installed on the host system
|
||||
|
||||
## Quick Start
|
||||
|
||||
1. Clone this repository and enter the directory:
|
||||
1. **Клонируй репозиторий**
|
||||
```bash
|
||||
git clone <repository-url> local-dns
|
||||
cd local-dns
|
||||
git clone ... && cd local-dns
|
||||
```
|
||||
|
||||
2. Initialize the project:
|
||||
2. **Настрой домен (опционально)**
|
||||
```bash
|
||||
./scripts/00-init.sh
|
||||
echo "LOCAL_DOMAIN=mikan" > .env
|
||||
```
|
||||
This creates a `.env` file from `.env.example` and sets up the directory structure.
|
||||
Замени `mikan` на желаемый суффикс (например, `home`).
|
||||
|
||||
3. Generate TLS certificates:
|
||||
3. **Инициализируй CA и базовый сертификат**
|
||||
```bash
|
||||
./scripts/01-generate-cert.sh
|
||||
./scripts/01-init-ca.sh
|
||||
```
|
||||
This creates trusted certificates for your local domain.
|
||||
- Создаст доверенный корневой сертификат (`ca/rootCA.pem`)
|
||||
- Сгенерирует `default.crt` для nginx-proxy
|
||||
|
||||
4. Start the core infrastructure:
|
||||
4. **Установи корневой сертификат в систему**
|
||||
Импортируй файл `ca/rootCA.pem` в хранилище **доверенных корневых центров сертификации**:
|
||||
- **Linux**:
|
||||
```bash
|
||||
sudo cp ca/rootCA.pem /usr/local/share/ca-certificates/mkcert-local.crt
|
||||
sudo update-ca-certificates
|
||||
```
|
||||
- **Windows/macOS**: двойной клик по файлу → «Доверять всегда» (macOS) или импорт в «Доверенные корневые центры» (Windows)
|
||||
|
||||
5. **Запусти инфраструктуру**
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
5. Add your first service (example: Gitea on port 3000):
|
||||
6. **Добавь сервис**
|
||||
```bash
|
||||
./scripts/add-service.sh gitea 3000
|
||||
./scripts/add-service.sh gitea
|
||||
```
|
||||
Then edit `services/gitea/docker-compose.yml` to set the correct image and volumes.
|
||||
Сервис будет доступен по:
|
||||
- `https://gitea.mikan`
|
||||
- `https://gitea.local`
|
||||
|
||||
6. Start the new service:
|
||||
```bash
|
||||
docker compose -f docker-compose.yml -f services/gitea/docker-compose.yml up -d
|
||||
\+ может пригодиться:
|
||||
|
||||
```bash
|
||||
Add-Content -Path "C:\Windows\System32\drivers\etc\hosts" -Value "10.0.0.3 youtrack.mikan"
|
||||
```
|
||||
|
||||
7. **Настрой сервис в Docker Compose**
|
||||
Убедись, что в `docker-compose.yml` сервиса указано:
|
||||
```yaml
|
||||
services:
|
||||
gitea:
|
||||
environment:
|
||||
- VIRTUAL_HOST=gitea.mikan,gitea.local
|
||||
- VIRTUAL_PORT=3000 # порт внутри контейнера
|
||||
networks:
|
||||
- devnet
|
||||
dns: 10.0.0.2 # обязательно для резолвинга доменов из контейнеров
|
||||
```
|
||||
|
||||
7. Visit `https://gitea.yourdomain` in your browser (replace `yourdomain` with your configured domain).
|
||||
## Важные замечания
|
||||
|
||||
## Configuration
|
||||
### DNS из контейнеров
|
||||
Контейнеры **не могут** резолвить `*.mikan` без явного указания DNS:
|
||||
```yaml
|
||||
dns: 10.0.0.2 # IP dnsmasq
|
||||
```
|
||||
Добавляй эту строку во все сервисы, которым нужен доступ к другим по домену.
|
||||
|
||||
Edit the `.env` file to customize your setup:
|
||||
### Обновление сертификатов
|
||||
При добавлении сервиса через `add-service.sh`:
|
||||
- Автоматически обновляется `domains.txt`
|
||||
- Генерируется новый `default.crt`
|
||||
- Перезагружается `nginx-proxy`
|
||||
|
||||
- `LOCAL_DOMAIN`: Your local domain suffix (default: `mikan`)
|
||||
- `PUBLIC_DOMAIN`: Optional public domain for Let's Encrypt certificates
|
||||
- `LETSENCRYPT_EMAIL`: Email for Let's Encrypt notifications
|
||||
- Network settings (`NGINX_IP`, `DNSMASQ_IP`, etc.)
|
||||
### Пути
|
||||
- Сертификаты: `nginx/certs/default.crt`
|
||||
- Домены: `domains.txt`
|
||||
- Корневой CA: `ca/rootCA.pem`
|
||||
|
||||
After changing `.env`, re-run the initialization and certificate scripts.
|
||||
## Расширение
|
||||
|
||||
## DNS Setup
|
||||
|
||||
### Linux/macOS
|
||||
|
||||
Use the included `dnsmasq` service for automatic DNS resolution:
|
||||
|
||||
```bash
|
||||
docker compose -f docker-compose.yml -f docker-compose.dnsmasq.yml up -d
|
||||
### Tailscale
|
||||
Добавь в `docker-compose.yml` сервис `tailscale` и объявляй дополнительные домены:
|
||||
```yaml
|
||||
environment:
|
||||
- VIRTUAL_HOST=gitea.mikan,gitea.local,gitea.yourname.ts.net
|
||||
```
|
||||
|
||||
Then configure your system to use `10.0.0.2` as the primary DNS server.
|
||||
|
||||
### Windows (WSL2)
|
||||
|
||||
Windows reserves port 53, so `dnsmasq` cannot run on the host. Instead:
|
||||
|
||||
1. Work inside WSL2
|
||||
2. Manually add entries to the Windows hosts file:
|
||||
```powershell
|
||||
# Run PowerShell as Administrator
|
||||
Add-Content -Path "C:\Windows\System32\drivers\etc\hosts" -Value "127.0.0.1 gitea.mikan"
|
||||
Add-Content -Path "C:\Windows\System32\drivers\etc\hosts" -Value "127.0.0.1 gitea.mikan.local"
|
||||
### Публичный домен
|
||||
1. Купи домен (например, `example.com`)
|
||||
2. В `.env` добавь:
|
||||
```env
|
||||
PUBLIC_DOMAIN=example.com
|
||||
```
|
||||
|
||||
## Certificate Trust
|
||||
|
||||
After running `./scripts/01-generate-cert.sh`, install the root certificate on your devices:
|
||||
|
||||
- **Linux**: Depends on distribution (usually via `update-ca-certificates`)
|
||||
- **macOS**:
|
||||
```bash
|
||||
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ca/rootCA.pem
|
||||
```
|
||||
- **Windows**:
|
||||
1. Copy `ca/rootCA.pem` to Windows
|
||||
2. Open `certmgr.msc`
|
||||
3. Import into "Trusted Root Certification Authorities"
|
||||
|
||||
## Adding Public Domain Support
|
||||
|
||||
To enable Let's Encrypt certificates for a public domain:
|
||||
|
||||
1. Set in `.env`:
|
||||
```ini
|
||||
PUBLIC_DOMAIN=yourdomain.com
|
||||
LETSENCRYPT_EMAIL=you@yourdomain.com
|
||||
3. В сервисах укажи:
|
||||
```yaml
|
||||
environment:
|
||||
- VIRTUAL_HOST=gitea.mikan,gitea.local,gitea.example.com
|
||||
- LETSENCRYPT_HOST=gitea.example.com
|
||||
```
|
||||
Сертификат для `example.com` получит `acme-companion`.
|
||||
|
||||
2. Re-run initialization:
|
||||
```bash
|
||||
./scripts/00-init.sh
|
||||
./scripts/01-generate-cert.sh
|
||||
```
|
||||
---
|
||||
|
||||
3. New services will automatically request Let's Encrypt certificates for the public domain.
|
||||
|
||||
## Service Management
|
||||
|
||||
- **Add a service**: `./scripts/add-service.sh <name> <port>`
|
||||
- **Start all**: `docker compose up -d`
|
||||
- **Start with dnsmasq**: `docker compose -f docker-compose.yml -f docker-compose.dnsmasq.yml up -d`
|
||||
- **Stop all**: `docker compose down`
|
||||
|
||||
All service data is stored in the `services/` directory and persists between restarts.
|
||||
Готово. Теперь все сервисы работают по HTTPS с валидными сертификатами.
|
||||
Reference in New Issue
Block a user