base container
This commit is contained in:
1
.env.example
Normal file
1
.env.example
Normal file
@@ -0,0 +1 @@
|
||||
DOMAIN=example.com
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -0,0 +1,4 @@
|
||||
/acme/
|
||||
/self-signed/
|
||||
/certdump/
|
||||
.env
|
||||
65
README.md
65
README.md
@@ -1,2 +1,65 @@
|
||||
# ansible-cloud
|
||||
# Konfiguracja Traefik
|
||||
|
||||
## 1. Przygotowanie plików konfiguracyjnych
|
||||
|
||||
### Zmień nazwę pliku `.env.example` na `.env`
|
||||
|
||||
```bash
|
||||
mv .env.example .env
|
||||
```
|
||||
|
||||
### Uzupełnij swoją nazwę domeny w `.env`
|
||||
|
||||
Otwórz plik `.env` i ustaw swoją domenę:
|
||||
|
||||
```ini
|
||||
DOMAIN=example.com
|
||||
```
|
||||
|
||||
### Uzupełnij swój adres e-mail w `config/traefik.yml`
|
||||
|
||||
Otwórz plik `config/traefik.yml` i dodaj swój adres e-mail:
|
||||
|
||||
```yaml
|
||||
email: your-email@example.com
|
||||
```
|
||||
|
||||
## 2. Uruchomienie usług
|
||||
|
||||
Uruchom kontenery w tle za pomocą Docker Compose:
|
||||
|
||||
```bash
|
||||
sudo docker compose up -d
|
||||
```
|
||||
|
||||
## 3. Dodawanie dodatkowych usług
|
||||
|
||||
Kolejne usługi można dodać do sieci `traefik_public`.
|
||||
|
||||
### Przykładowa konfiguracja
|
||||
|
||||
```yaml
|
||||
services:
|
||||
example-service:
|
||||
image: my-custom-image
|
||||
networks:
|
||||
- traefik_public # Usługa dołączona do sieci Traefik
|
||||
labels:
|
||||
- traefik.enable=true # Włącz obsługę przez Traefik
|
||||
- traefik.http.routers.example.rule=Host(`example.${DOMAIN}`) # Reguła przekierowania
|
||||
- traefik.http.services.example-service.loadbalancer.server.port=8080 # Port usługi
|
||||
- traefik.http.routers.example.entrypoints=websecure # Użycie wejścia HTTPS
|
||||
- traefik.http.routers.example.tls=true # Włączenie TLS
|
||||
- traefik.http.routers.example.tls.certresolver=tls-resolver # Użycie Let's Encrypt
|
||||
- com.centurylinklabs.watchtower.enable=true # Jeśli jest watchtower
|
||||
|
||||
networks:
|
||||
traefik_public:
|
||||
external: true # Użycie zewnętrznej sieci Traefik
|
||||
```
|
||||
|
||||
## 4. Informacje dodatkowe
|
||||
|
||||
- `traefik_public` to zewnętrzna sieć Traefik, do której należy dodać nowe usługi.
|
||||
- `tls-resolver` to mechanizm uzyskiwania certyfikatów SSL, musi być poprawnie skonfigurowany w `traefik.yml`.
|
||||
- Watchtower (`com.centurylinklabs.watchtower.enable=true`) automatycznie aktualizuje kontenery, jeśli wykryje nową wersję obrazu.
|
||||
|
||||
42
compose.yaml
Normal file
42
compose.yaml
Normal file
@@ -0,0 +1,42 @@
|
||||
services:
|
||||
traefik:
|
||||
image: traefik
|
||||
container_name: traefik
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 80:80 # HTTP
|
||||
- 443:443/tcp # HTTPS HTTP1/2
|
||||
- 443:443/udp # HTTPS HTTP3
|
||||
# - 8080:8080 # TREFIK DASHBOARD
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro"
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- ./config/dynamic.yml:/etc/traefik/dynamic.yml:ro
|
||||
- ./config/traefik.yml:/etc/traefik/traefik.yml:ro
|
||||
- ./acme:/etc/traefik/acme
|
||||
- ./self-signed:/etc/traefik/ssl
|
||||
networks:
|
||||
- traefik_public
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.http.routers.traefik.rule=Host(`traefik.${DOMAIN}`)
|
||||
- traefik.http.services.traefik-traefik.loadbalancer.server.port=8080
|
||||
- traefik.http.routers.traefik.entrypoints=websecure
|
||||
- traefik.http.routers.traefik.tls=true
|
||||
- traefik.http.routers.traefik.tls.certresolver=certresolver
|
||||
- "com.centurylinklabs.watchtower.enable=true"
|
||||
|
||||
certdumper:
|
||||
image: ghcr.io/kereis/traefik-certs-dumper:latest
|
||||
restart: unless-stopped
|
||||
container_name: certdumper
|
||||
volumes:
|
||||
- ./acme:/traefik:ro
|
||||
- ./certdump:/output:rw
|
||||
network_mode: none
|
||||
environment:
|
||||
COMBINED_PEM: fullchain.pem
|
||||
|
||||
networks:
|
||||
traefik_public:
|
||||
external: true
|
||||
33
config/dynamic.yml
Normal file
33
config/dynamic.yml
Normal file
@@ -0,0 +1,33 @@
|
||||
################################################################
|
||||
# Self-signed certificate configuration
|
||||
################################################################
|
||||
|
||||
# tls:
|
||||
# stores:
|
||||
# default:
|
||||
# defaultCertificate:
|
||||
# certFile: /etc/traefik/ssl/local-domain.crt
|
||||
# keyFile: /etc/traefik/ssl/local-domain.key
|
||||
|
||||
################################################################
|
||||
# Middlewares configuration
|
||||
################################################################
|
||||
|
||||
# http:
|
||||
# middlewares:
|
||||
# authentik:
|
||||
# forwardAuth:
|
||||
# address: http://server:9000/outpost.goauthentik.io/auth/traefik
|
||||
# trustForwardHeader: true
|
||||
# authResponseHeaders:
|
||||
# - X-authentik-username
|
||||
# - X-authentik-groups
|
||||
# - X-authentik-email
|
||||
# - X-authentik-name
|
||||
# - X-authentik-uid
|
||||
# - X-authentik-jwt
|
||||
# - X-authentik-meta-jwks
|
||||
# - X-authentik-meta-outpost
|
||||
# - X-authentik-meta-provider
|
||||
# - X-authentik-meta-app
|
||||
# - X-authentik-meta-version
|
||||
66
config/traefik.yml
Normal file
66
config/traefik.yml
Normal file
@@ -0,0 +1,66 @@
|
||||
################################################################
|
||||
# Global configuration
|
||||
################################################################
|
||||
|
||||
global:
|
||||
checkNewVersion: true
|
||||
sendAnonymousUsage: true
|
||||
|
||||
################################################################
|
||||
# EntryPoints configuration
|
||||
################################################################
|
||||
|
||||
entryPoints:
|
||||
web:
|
||||
address: :80
|
||||
http:
|
||||
redirections:
|
||||
entryPoint:
|
||||
to: "websecure"
|
||||
scheme: "https"
|
||||
|
||||
websecure:
|
||||
address: :443
|
||||
http3: {}
|
||||
|
||||
################################################################
|
||||
# API and dashboard configuration
|
||||
################################################################
|
||||
|
||||
api:
|
||||
insecure: true
|
||||
dashboard: true
|
||||
|
||||
################################################################
|
||||
# Docker configuration backend
|
||||
################################################################
|
||||
|
||||
providers:
|
||||
docker:
|
||||
endpoint: "unix:///var/run/docker.sock"
|
||||
exposedByDefault: false
|
||||
network: "traefik_public"
|
||||
file:
|
||||
filename: "/etc/traefik/dynamic.yml"
|
||||
watch: true
|
||||
providersThrottleDuration: 10
|
||||
|
||||
certificatesResolvers:
|
||||
tls-resolver:
|
||||
acme:
|
||||
email: mail@example.com
|
||||
storage: "/etc/traefik/acme/acme.json"
|
||||
tlsChallenge: {}
|
||||
|
||||
################################################################
|
||||
# Logging
|
||||
################################################################
|
||||
|
||||
metrics:
|
||||
prometheus:
|
||||
buckets:
|
||||
- 0.1
|
||||
- 0.3
|
||||
- 1.2
|
||||
- 5.0
|
||||
addRoutersLabels: true
|
||||
Reference in New Issue
Block a user