Skip to content

Commit

Permalink
chore(domains): remove manipulate traefik on register routes
Browse files Browse the repository at this point in the history
  • Loading branch information
igr-santos committed Dec 13, 2023
1 parent b4e254e commit b6be9ef
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 153 deletions.
118 changes: 59 additions & 59 deletions app/contrib/domains/traefik/apps.py
Original file line number Diff line number Diff line change
@@ -1,76 +1,76 @@
from django.apps import AppConfig
from django.db.models.signals import post_save, post_delete
from django.conf import settings
# from django.db.models.signals import post_save, post_delete
# from django.conf import settings


from etcd3 import Client
# from etcd3 import Client

initial_config = [
# Setup inicial
(
"traefik/tls/options/default/cipherSuites/0",
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
),
(
"traefik/tls/options/default/cipherSuites/1",
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
),
(
"traefik/tls/options/default/cipherSuites/2",
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
),
(
"traefik/tls/options/default/cipherSuites/3",
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
),
(
"traefik/tls/options/default/cipherSuites/4",
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",
),
(
"traefik/tls/options/default/cipherSuites/5",
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
),
("traefik/tls/options/default/minVersion", "VersionTLS12"),
("traefik/http/middlewares/securityHeader/headers/contenttypenosniff", "true"),
("traefik/http/middlewares/securityHeader/headers/framedeny", "false"),
("traefik/http/middlewares/securityHeader/headers/sslredirect", "true"),
("traefik/http/middlewares/securityHeader/headers/stsincludesubdomains", "true"),
("traefik/http/middlewares/securityHeader/headers/stspreload", "true"),
("traefik/http/middlewares/securityHeader/headers/stsseconds", "63072000"),
]
# initial_config = [
# # Setup inicial
# (
# "traefik/tls/options/default/cipherSuites/0",
# "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
# ),
# (
# "traefik/tls/options/default/cipherSuites/1",
# "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
# ),
# (
# "traefik/tls/options/default/cipherSuites/2",
# "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
# ),
# (
# "traefik/tls/options/default/cipherSuites/3",
# "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
# ),
# (
# "traefik/tls/options/default/cipherSuites/4",
# "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",
# ),
# (
# "traefik/tls/options/default/cipherSuites/5",
# "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
# ),
# ("traefik/tls/options/default/minVersion", "VersionTLS12"),
# ("traefik/http/middlewares/securityHeader/headers/contenttypenosniff", "true"),
# ("traefik/http/middlewares/securityHeader/headers/framedeny", "false"),
# ("traefik/http/middlewares/securityHeader/headers/sslredirect", "true"),
# ("traefik/http/middlewares/securityHeader/headers/stsincludesubdomains", "true"),
# ("traefik/http/middlewares/securityHeader/headers/stspreload", "true"),
# ("traefik/http/middlewares/securityHeader/headers/stsseconds", "63072000"),
# ]


initial_web_application_config = [
("traefik/http/routers/0-public-staging-bonde-org/tls", "true"),
("traefik/http/routers/0-public-staging-bonde-org/tls/certresolver", "myresolver"),
("traefik/http/routers/0-public-staging-bonde-org/service", "webpage@docker"),
# Configura todas as entradas possíveis
("traefik/http/routers/0-public-staging-bonde-org/rule", "HostRegexp(`{host:.+}`)"),
("traefik/http/routers/0-public-staging-bonde-org/tls/domains/0/main", "staging.bonde.org"),
("traefik/http/routers/0-public-staging-bonde-org/tls/domains/0/sans/0", "*.staging.bonde.org"),
]
# initial_web_application_config = [
# ("traefik/http/routers/0-public-staging-bonde-org/tls", "true"),
# ("traefik/http/routers/0-public-staging-bonde-org/tls/certresolver", "myresolver"),
# ("traefik/http/routers/0-public-staging-bonde-org/service", "webpage@docker"),
# # Configura todas as entradas possíveis
# ("traefik/http/routers/0-public-staging-bonde-org/rule", "HostRegexp(`{host:.+}`)"),
# ("traefik/http/routers/0-public-staging-bonde-org/tls/domains/0/main", "staging.bonde.org"),
# ("traefik/http/routers/0-public-staging-bonde-org/tls/domains/0/sans/0", "*.staging.bonde.org"),
# ]


class TraefikAppConfig(AppConfig):
name = "contrib.domains.traefik"

def ready(self):
import os
# def ready(self):
# import os

if not os.getenv("DISABLE_TRAEFIK", False):
client = Client(host=settings.ETCD_HOST, port=settings.ETCD_PORT)
# if not os.getenv("DISABLE_TRAEFIK", False):
# client = Client(host=settings.ETCD_HOST, port=settings.ETCD_PORT)

configs = []
configs.extend(initial_config)
configs.extend(initial_web_application_config)
# configs = []
# configs.extend(initial_config)
# configs.extend(initial_web_application_config)

for key_value in configs:
client.put(key=key_value[0], value=key_value[1])
# for key_value in configs:
# client.put(key=key_value[0], value=key_value[1])


# Signals configuration
from . import signals, models
# # Signals configuration
# from . import signals, models

post_save.connect(signals.update_traefik_config, sender=models.Route)
post_delete.connect(signals.delete_traefik_config, sender=models.Route)
# post_save.connect(signals.update_traefik_config, sender=models.Route)
# post_delete.connect(signals.delete_traefik_config, sender=models.Route)
188 changes: 94 additions & 94 deletions deploy/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,100 +1,100 @@
services:
traefik:
image: "traefik:v2.9"
depends_on:
- etcd
command:
# API
- "--global.checknewversion=${TRAEFIK_CHECK_NEW_VERSION:-false}"
- "--global.sendanonymoususage=${TRAEFIK_SEND_ANONYMOUS_USAGE:-false}"
- "--api.insecure=true"
# Providers
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.defaultRule=Host(`{{ index .Labels \"com.docker.compose.service\"}}.${DEFAULT_DOMAIN_RULE:-staging.bonde.org}`)"
# traefik:
# image: "traefik:v2.9"
# depends_on:
# - etcd
# command:
# # API
# - "--global.checknewversion=${TRAEFIK_CHECK_NEW_VERSION:-false}"
# - "--global.sendanonymoususage=${TRAEFIK_SEND_ANONYMOUS_USAGE:-false}"
# - "--api.insecure=true"
# # Providers
# - "--providers.docker=true"
# - "--providers.docker.exposedbydefault=false"
# - "--providers.docker.defaultRule=Host(`{{ index .Labels \"com.docker.compose.service\"}}.${DEFAULT_DOMAIN_RULE:-staging.bonde.org}`)"

- "--providers.etcd=true"
- "--providers.etcd.endpoints=etcd:2379"
- "--providers.etcd.rootkey=traefik"
# Logs
- "--log.filepath=/logs/traefik.log"
- "--log.format=json"
- "--log.level=${TRAEFIK_LOG_LEVEL:-ERROR}"
- "--metrics.prometheus"
- "--accesslog.filepath=/logs/access.log"
- "--accesslog.format=json"
# Entrypoints
- "--entrypoints.web.address=:80"
- "--entrypoints.web.http.redirections.entryPoint.to=websecure"
- "--entrypoints.web.http.redirections.entryPoint.scheme=https"
- "--entrypoints.web.http.redirections.entrypoint.permanent=true"
- "--entrypoints.websecure.address=:443"
- "--entrypoints.websecure.http.middlewares=securityHeader@etcd"
#
- "--pilot.token=${TRAEFIK_PILOT_TOKEN:-}"
- "--ping"
- "--certificatesresolvers.myresolver.acme.tlschallenge=true"
- "--certificatesresolvers.myresolver.acme.email=${DEFAULT_EMAIL_ACME:[email protected]}"
- "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
- "--certificatesresolvers.myresolver.acme.dnschallenge.provider=route53"
restart: always
healthcheck:
test: ['CMD', 'traefik', 'healthcheck', '--ping']
interval: 10s
timeout: 10s
retries: 5
ports:
- "80:80"
- "443:443"
# - "8080:8080"
# networks:
# - bonde
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- letsencrypt:/letsencrypt
# env_file:
# - .env
# environment:
# AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID:-xxxxxxx}
# AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY:-xxxxxx}
# AWS_REGION: ${AWS_REGION:-us-east-1}
labels:
- traefik.enable=true
# global redirection: https (www.) to https
- traefik.http.routers.wwwsecure-catchall.rule=HostRegexp(`{host:(www\\.).+}`)
- traefik.http.routers.wwwsecure-catchall.entrypoints=websecure
- traefik.http.routers.wwwsecure-catchall.tls=true
- traefik.http.routers.wwwsecure-catchall.middlewares=wwwtohttps
# middleware: http(s)://(www.) to https://
- traefik.http.middlewares.wwwtohttps.redirectregex.regex=^https?://(?:www\\.)?(.+)
- traefik.http.middlewares.wwwtohttps.redirectregex.replacement=https://$${1}
- traefik.http.middlewares.wwwtohttps.redirectregex.permanent=true
# export traefik dashboard
- traefik.http.services.traefik.loadbalancer.server.port=8080
- traefik.http.routers.traefik.tls=true
- traefik.http.routers.traefik.tls.certresolver=myresolver
# - "--providers.etcd=true"
# - "--providers.etcd.endpoints=etcd:2379"
# - "--providers.etcd.rootkey=traefik"
# # Logs
# - "--log.filepath=/logs/traefik.log"
# - "--log.format=json"
# - "--log.level=${TRAEFIK_LOG_LEVEL:-ERROR}"
# - "--metrics.prometheus"
# - "--accesslog.filepath=/logs/access.log"
# - "--accesslog.format=json"
# # Entrypoints
# - "--entrypoints.web.address=:80"
# - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
# - "--entrypoints.web.http.redirections.entryPoint.scheme=https"
# - "--entrypoints.web.http.redirections.entrypoint.permanent=true"
# - "--entrypoints.websecure.address=:443"
# - "--entrypoints.websecure.http.middlewares=securityHeader@etcd"
# #
# - "--pilot.token=${TRAEFIK_PILOT_TOKEN:-}"
# - "--ping"
# - "--certificatesresolvers.myresolver.acme.tlschallenge=true"
# - "--certificatesresolvers.myresolver.acme.email=${DEFAULT_EMAIL_ACME:[email protected]}"
# - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
# - "--certificatesresolvers.myresolver.acme.dnschallenge.provider=route53"
# restart: always
# healthcheck:
# test: ['CMD', 'traefik', 'healthcheck', '--ping']
# interval: 10s
# timeout: 10s
# retries: 5
# ports:
# - "80:80"
# - "443:443"
# # - "8080:8080"
# # networks:
# # - bonde
# volumes:
# - "/var/run/docker.sock:/var/run/docker.sock:ro"
# - letsencrypt:/letsencrypt
# # env_file:
# # - .env
# # environment:
# # AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID:-xxxxxxx}
# # AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY:-xxxxxx}
# # AWS_REGION: ${AWS_REGION:-us-east-1}
# labels:
# - traefik.enable=true
# # global redirection: https (www.) to https
# - traefik.http.routers.wwwsecure-catchall.rule=HostRegexp(`{host:(www\\.).+}`)
# - traefik.http.routers.wwwsecure-catchall.entrypoints=websecure
# - traefik.http.routers.wwwsecure-catchall.tls=true
# - traefik.http.routers.wwwsecure-catchall.middlewares=wwwtohttps
# # middleware: http(s)://(www.) to https://
# - traefik.http.middlewares.wwwtohttps.redirectregex.regex=^https?://(?:www\\.)?(.+)
# - traefik.http.middlewares.wwwtohttps.redirectregex.replacement=https://$${1}
# - traefik.http.middlewares.wwwtohttps.redirectregex.permanent=true
# # export traefik dashboard
# - traefik.http.services.traefik.loadbalancer.server.port=8080
# - traefik.http.routers.traefik.tls=true
# - traefik.http.routers.traefik.tls.certresolver=myresolver

etcd:
image: 'bitnami/etcd:latest'
environment:
- ALLOW_NONE_AUTHENTICATION=yes
- ETCD_ADVERTISE_CLIENT_URLS=http://etcd:2379
# - ETCD_PROXY=on
- ETCD_ENABLE_V2=true
# - ETCD_
- ETCDCTL_API=3
volumes:
- etcd_data:/bitnami/etcd
ports:
- 2379:2379
- 2380:2380
# etcd:
# image: 'bitnami/etcd:latest'
# environment:
# - ALLOW_NONE_AUTHENTICATION=yes
# - ETCD_ADVERTISE_CLIENT_URLS=http://etcd:2379
# # - ETCD_PROXY=on
# - ETCD_ENABLE_V2=true
# # - ETCD_
# - ETCDCTL_API=3
# volumes:
# - etcd_data:/bitnami/etcd
# ports:
# - 2379:2379
# - 2380:2380

cms:
image: ${DOCKER_IMAGE:-nossas/cms:main}
restart: "${DOCKER_RESTART_POLICY:-unless-stopped}"
pull_policy: always
depends_on:
- etcd
# depends_on:
# - etcd
environment:
- DEBUG=${DEBUG:-True}
- ALLOWED_HOSTS=${ALLOWED_HOSTS:-"docker.localhost"}
Expand All @@ -118,11 +118,11 @@ services:
- traefik.http.routers.cms.tls.certresolver=myresolver
- traefik.http.routers.cms.rule=${TRAEFIK_ROUTERS_RULE:-"HostRegexp(`cms.staging.bonde.org`)"}

volumes:
letsencrypt:
driver: local
etcd_data:
driver: local
# volumes:
# letsencrypt:
# driver: local
# etcd_data:
# driver: local

networks:
default:
Expand Down

0 comments on commit b6be9ef

Please sign in to comment.