Compare commits

..

2 Commits

Author SHA1 Message Date
15706201e9 testing 2023-12-08 04:23:22 -05:00
40083892ff testing 2023-12-08 03:22:09 -05:00
4 changed files with 72 additions and 29 deletions

View File

@@ -6,9 +6,7 @@ Encrypt. While similar, the docker-compose files available here cater to
different use cases for deploying Traefik. different use cases for deploying Traefik.
## Add services to Traefik ## Add services to Traefik
1. Define the external traefik network on the top-level networks key 1. Define the external traefik network on the top-level networks key
``` ```
networks: networks:
traefik: traefik:
@@ -16,14 +14,12 @@ networks:
``` ```
2. Attach your web container to Traefik's network via the service-level `networks` key 2. Attach your web container to Traefik's network via the service-level `networks` key
``` ```
networks: networks:
- traefik - traefik
``` ```
3. Define routing for Traefik in labels, replacing "examplerouter" with something unique 3. Define routing for Traefik in labels, replacing "examplerouter" with something unique
``` ```
labels: labels:
traefik.http.routers.examplerouter.rule: Host(`www.example.org`) traefik.http.routers.examplerouter.rule: Host(`www.example.org`)
@@ -34,35 +30,31 @@ networks:
``` ```
## Variables ## Variables
Here's a brief explanation of the variables used in the docker-compose files: Here's a brief explanation of the variables used in the docker-compose files:
### Docker Settings ### Docker Settings
- `IMAGE`: The name of the Docker image (default: `traefik`). - `IMAGE`: The name of the Docker image (default: `traefik`).
- `VERSION`: The tag of the Docker image (required, no default). - `VERSION`: The tag of the Docker image (default: `latest`).
- `NAME`: The name assigned to the created container (default: `traefik`). - `NAME`: The name assigned to the created container (default: `traefik`).
### Traefik Settings ### Traefik Settings
- `DASHBOARD`: Enable(=true) or disable(=false) the Traefik API dashboard (default: `true`).
- `DASHBOARD`: Enable(=true) or disable(=false) the Traefik API dashboard (default: `false`).
- `DOMAIN`: The domain name where Traefik's dashboard is accessible (default: `traefik.local.krislamo.org`). - `DOMAIN`: The domain name where Traefik's dashboard is accessible (default: `traefik.local.krislamo.org`).
- `ENTRYPOINT`: The entry point for the dashboard (default: `local`). - `ENTRYPOINT`: The entry point for the dashboard (default: `local`).
- `EXPOSED_BY_DEFAULT`: Expose Docker containers by default without needing specific labels (default: `false`). - `EXPOSED_BY_DEFAULT`: Expose Docker containers by default without needing specific labels (default: `false`).
### Network Settings ### Network Settings
- `NETWORK`: The Docker network to be used (default: `traefik`). - `NETWORK`: The Docker network to be used (default: `traefik`).
- `WEB_PORT`: Binding for the regular HTTP traffic (defaults vary). - `WEB_PORT`: Binding for the regular HTTP traffic (default: `0.0.0.0:80:80`).
- `WEBSECURE_PORT`: Binding for HTTPS traffic (default: `0.0.0.0:443:443`, only on HTTPS version). - `WEBSECURE_PORT`: Binding for HTTPS traffic (default: `0.0.0.0:443:443`).
- `LOCAL_PORT`: Binding for local HTTPS traffic (default: `127.0.0.1:8443:8443`). - `LOCAL_PORT`: Binding for local HTTPS traffic (default: `127.0.0.1:8443:8443`).
### Other Settings ### Other Settings
- `ENABLE`: Enable(=true) or disable(=false) Traefik to expose its API and dashboard (default: `false`).
- `LOG_LEVEL`: Logging level (default: `ERROR`). - `LOG_LEVEL`: Logging level (default: `ERROR`).
- `DEBUG`: Enable(=true) or turn off(=false) API debugging (default: `false`). - `DEBUG`: Enable(=true) or turn off(=false) API debugging (default: `false`).
## License
## License
This project is released under the 0BSD license, which allows for unrestricted This project is released under the 0BSD license, which allows for unrestricted
use, modification, and distribution. use, modification, and distribution.

47
docker-compose.swarm.yml Normal file
View File

@@ -0,0 +1,47 @@
version: '3.8'
volumes:
traefik:
networks:
traefik:
name: traefik
services:
traefik:
image: "${IMAGE:-traefik}:${VERSION:-latest}"
command:
- --providers.docker=true
- --providers.docker.swarmMode=true
- --providers.docker.exposedbydefault=${EXPOSED_BY_DEFAULT:-false}
- --api.dashboard=${DASHBOARD:-true}
- --api.debug=${DEBUG:-false}
- --log.level=${LOG_LEVEL:-ERROR}
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --entrypoints.web.http.redirections.entrypoint.to=websecure
- --entrypoints.web.http.redirections.entrypoint.scheme=https
- --entrypoints.web.http.redirections.entrypoint.permanent=true
ports:
- "${WEB_PORT:-0.0.0.0:80:80}"
- "${WEBSECURE_PORT:-0.0.0.0:443:443}"
networks:
- traefik
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- "traefik:/etc/traefik"
deploy:
mode: global
placement:
constraints:
- node.role == manager
labels:
- "traefik.http.routers.${ROUTER:-traefik}.rule=Host(`${DOMAIN:-traefik.local.krislamo.org}`)"
- "traefik.http.routers.${ROUTER:-traefik}.service=api@internal"
- "traefik.http.routers.${ROUTER:-traefik}.entrypoints=${ENTRYPOINT:-websecure}"
- "traefik.http.routers.${ROUTER:-traefik}.tls=${ENABLE_TLS:-true}"
- "traefik.http.services.${SERVICE:-traefik}.loadbalancer.server.port=80"
- "traefik.http.middlewares.internalonly.ipwhitelist.sourcerange=127.0.0.1/32"
- "traefik.http.routers.${ROUTER:-traefik}.middlewares=internalonly"
- "traefik.docker.network=${NETWORK:-traefik}"
- "traefik.enable=${ENABLE:-true}"

View File

@@ -1,3 +1,5 @@
version: '3.8'
volumes: volumes:
traefik: traefik:
@@ -7,31 +9,26 @@ networks:
services: services:
traefik: traefik:
image: "${IMAGE:-traefik}:${VERSION:?}" image: "${IMAGE:-traefik}:${VERSION:-latest}"
container_name: "${NAME:-traefik}" container_name: "${NAME:-traefik}"
command: command:
- --providers.docker=true - --providers.docker=true
- --providers.docker.exposedbydefault=${EXPOSED_BY_DEFAULT:-false} - --providers.docker.exposedbydefault=${EXPOSED_BY_DEFAULT:-false}
- --api.dashboard=${DASHBOARD:-false} - --api.dashboard=${DASHBOARD:-true}
- --api.debug=${DEBUG:-false} - --api.debug=${DEBUG:-false}
- --log.level=${LOG_LEVEL:-ERROR} - --log.level=${LOG_LEVEL:-ERROR}
- --entrypoints.web.address=:80 - --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --entrypoints.local.address=:8443 - --entrypoints.local.address=:8443
- --entrypoints.web.http.redirections.entrypoint.to=websecure
- --entrypoints.web.http.redirections.entrypoint.scheme=https
- --entrypoints.web.http.redirections.entrypoint.permanent=true
ports: ports:
- "${WEB_PORT:-0.0.0.0:80:80}" - "${WEB_PORT:-127.0.0.1:80:80}"
- "${WEBSECURE_PORT:-0.0.0.0:443:443}"
- "${LOCAL_PORT:-127.0.0.1:8443:8443}" - "${LOCAL_PORT:-127.0.0.1:8443:8443}"
labels: labels:
- "traefik.http.routers.${ROUTER:-traefik}.rule=Host(`${DOMAIN:-traefik.local.krislamo.org}`)" - "traefik.http.routers.${ROUTER:-traefik}.rule=Host(`${DOMAIN:-traefik.local.krislamo.org}`)"
- "traefik.http.routers.${ROUTER:-traefik}.service=api@internal" - "traefik.http.routers.${ROUTER:-traefik}.service=api@internal"
- "traefik.http.routers.${ROUTER:-traefik}.entrypoints=${ENTRYPOINT:-local}" - "traefik.http.routers.${ROUTER:-traefik}.entrypoints=${ENTRYPOINT:-local}"
- "traefik.http.routers.${ROUTER:-traefik}.tls=${DASHBOARD_TLS:-true}" - "traefik.http.routers.${ROUTER:-traefik}.tls=${ENABLE_TLS:-true}"
- "traefik.docker.network=${NETWORK:-traefik}" - "traefik.docker.network=${NETWORK:-traefik}"
- "traefik.enable=${DASHBOARD:-false}" - "traefik.enable=${ENABLE:-false}"
networks: networks:
- traefik - traefik
volumes: volumes:

View File

@@ -1,3 +1,5 @@
version: '3.8'
volumes: volumes:
traefik: traefik:
@@ -7,26 +9,31 @@ networks:
services: services:
traefik: traefik:
image: "${IMAGE:-traefik}:${VERSION:?}" image: "${IMAGE:-traefik}:${VERSION:-latest}"
container_name: "${NAME:-traefik}" container_name: "${NAME:-traefik}"
command: command:
- --providers.docker=true - --providers.docker=true
- --providers.docker.exposedbydefault=${EXPOSED_BY_DEFAULT:-false} - --providers.docker.exposedbydefault=${EXPOSED_BY_DEFAULT:-false}
- --api.dashboard=${DASHBOARD:-false} - --api.dashboard=${DASHBOARD:-true}
- --api.debug=${DEBUG:-false} - --api.debug=${DEBUG:-false}
- --log.level=${LOG_LEVEL:-ERROR} - --log.level=${LOG_LEVEL:-ERROR}
- --entrypoints.web.address=:80 - --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --entrypoints.local.address=:8443 - --entrypoints.local.address=:8443
- --entrypoints.web.http.redirections.entrypoint.to=websecure
- --entrypoints.web.http.redirections.entrypoint.scheme=https
- --entrypoints.web.http.redirections.entrypoint.permanent=true
ports: ports:
- "${WEB_PORT:-127.0.0.1:8000:80}" - "${WEB_PORT:-0.0.0.0:80:80}"
- "${WEBSECURE_PORT:-0.0.0.0:443:443}"
- "${LOCAL_PORT:-127.0.0.1:8443:8443}" - "${LOCAL_PORT:-127.0.0.1:8443:8443}"
labels: labels:
- "traefik.http.routers.${ROUTER:-traefik}.rule=Host(`${DOMAIN:-traefik.local.krislamo.org}`)" - "traefik.http.routers.${ROUTER:-traefik}.rule=Host(`${DOMAIN:-traefik.local.krislamo.org}`)"
- "traefik.http.routers.${ROUTER:-traefik}.service=api@internal" - "traefik.http.routers.${ROUTER:-traefik}.service=api@internal"
- "traefik.http.routers.${ROUTER:-traefik}.entrypoints=${ENTRYPOINT:-local}" - "traefik.http.routers.${ROUTER:-traefik}.entrypoints=${ENTRYPOINT:-local}"
- "traefik.http.routers.${ROUTER:-traefik}.tls=${DASHBOARD_TLS:-true}" - "traefik.http.routers.${ROUTER:-traefik}.tls=${ENABLE_TLS:-true}"
- "traefik.docker.network=${NETWORK:-traefik}" - "traefik.docker.network=${NETWORK:-traefik}"
- "traefik.enable=${DASHBOARD:-false}" - "traefik.enable=${ENABLE:-false}"
networks: networks:
- traefik - traefik
volumes: volumes: