Skip to content

Commit

Permalink
traefik https
Browse files Browse the repository at this point in the history
  • Loading branch information
bouttier committed Sep 11, 2023
1 parent c9ad9cb commit 43e00d7
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ HOST="localhost"
HTTP_PORT=8081
HTTPS_PORT=8083

ACME_EMAIL=""

POSTGRES_USER="geonatadmin"
POSTGRES_PASSWORD="geonatpasswd"
POSTGRES_HOST="postgres"
Expand Down
2 changes: 2 additions & 0 deletions .env.prod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ HOST="example.com"
HTTP_PORT=80
HTTPS_PORT=443

ACME_EMAIL=""

POSTGRES_USER="geonatadmin"
POSTGRES_PASSWORD="geonatpasswd"
POSTGRES_HOST="postgres"
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.env
config/*
data/taxhub/static/*
data/geonature/media/*
/config/
/data/
!data/**/.gitkeep
!data/**/*.sample
*.swp
Empty file added config/traefik/.gitkeep
Empty file.
28 changes: 19 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ services:
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.web.http.redirections.entrypoint.to=:${HTTPS_PORT}" # use binded port instead of websecure
- "--entrypoints.web.http.redirections.entrypoint.scheme=https"
- "--entrypoints.websecure.address=:443"
- "--certificatesResolvers.acme-resolver.acme.email=${ACME_EMAIL}"
- "--certificatesResolvers.acme-resolver.acme.storage=/etc/traefik/certs/acme.json"
- "--certificatesResolvers.acme-resolver.acme.tlsChallenge=true"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./data/traefik/certs:/certs
- ./config/traefik:/etc/traefik/dynamic
- ./data/traefik/certs:/etc/traefik/certs
ports:
- ${HTTP_PORT:-80}:80
- ${HTTPS_PORT:-443}:443
Expand Down Expand Up @@ -93,8 +99,9 @@ services:
- PYTHONPATH=/dist/config
labels:
- "traefik.enable=true"
- "traefik.http.routers.usershub.rule=Host(`${USERSHUB_DOMAIN}`) && PathPrefix(`${USERSHUB_PREFIX:-/usershub}`)"
- "traefik.http.routers.usershub.entrypoints=web"
- "traefik.http.routers.usershub.rule=Host(`${USERSHUB_DOMAIN}`) && PathPrefix(`${USERSHUB_PREFIX}`)"
- "traefik.http.routers.usershub.entrypoints=websecure"
- "traefik.http.routers.usershub.tls.certResolver=acme-resolver"

taxhub:
<<: *defaults
Expand All @@ -112,8 +119,9 @@ services:
- PYTHONPATH=/dist/config
labels:
- "traefik.enable=true"
- "traefik.http.routers.taxhub.rule=Host(`${TAXHUB_DOMAIN}`) && PathPrefix(`${TAXHUB_PREFIX:-/taxhub}`)"
- "traefik.http.routers.taxhub.entrypoints=web"
- "traefik.http.routers.taxhub.rule=Host(`${TAXHUB_DOMAIN}`) && PathPrefix(`${TAXHUB_PREFIX}`)"
- "traefik.http.routers.taxhub.entrypoints=websecure"
- "traefik.http.routers.taxhub.tls.certResolver=acme-resolver"

geonature-worker:
<<: *geonature-backend-defaults
Expand All @@ -140,8 +148,9 @@ services:
- ${GEONATURE_MEDIA_DIRECTORY:-./data/geonature/media}:/dist/media
labels:
- "traefik.enable=true"
- "traefik.http.routers.geonature-backend.rule=Host(`${GEONATURE_DOMAIN}`) && PathPrefix(`${GEONATURE_BACKEND_PREFIX:-/geonature/api}`)"
- "traefik.http.routers.geonature-backend.entrypoints=web"
- "traefik.http.routers.geonature-backend.rule=Host(`${GEONATURE_DOMAIN}`) && PathPrefix(`${GEONATURE_BACKEND_PREFIX}`)"
- "traefik.http.routers.geonature-backend.entrypoints=websecure"
- "traefik.http.routers.geonature-backend.tls.certResolver=acme-resolver"

geonature-frontend:
image: ${GEONATURE_FRONTEND_IMAGE}
Expand All @@ -150,8 +159,9 @@ services:
- API_ENDPOINT="${GEONATURE_BACKEND_PROTOCOL}://${GEONATURE_BACKEND_HOST}${GEONATURE_BACKEND_PREFIX}"
labels:
- "traefik.enable=true"
- "traefik.http.routers.geonature.rule=Host(`${GEONATURE_DOMAIN}`) && PathPrefix(`${GEONATURE_FRONTEND_PREFIX:-/}`)"
- "traefik.http.routers.geonature.entrypoints=web"
- "traefik.http.routers.geonature.rule=Host(`${GEONATURE_DOMAIN}`) && PathPrefix(`${GEONATURE_FRONTEND_PREFIX}`)"
- "traefik.http.routers.geonature.entrypoints=websecure"
- "traefik.http.routers.geonature.tls.certResolver=acme-resolver"

volumes:
redis:
Expand Down

0 comments on commit 43e00d7

Please sign in to comment.