From 333ec49ee94c455ed6d2d5c5e0cefe7a2e7ccef5 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 25 Feb 2020 12:04:12 +0200 Subject: [PATCH] Updated cert configs --- app/init.php | 1 + app/workers/certificates.php | 10 ++++++++++ docker-compose.yml | 12 +++++------- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/init.php b/app/init.php index 3390ea378..d74c3bfd4 100644 --- a/app/init.php +++ b/app/init.php @@ -29,6 +29,7 @@ const APP_VERSION_STABLE = '0.5.0'; const APP_STORAGE_UPLOADS = '/storage/uploads'; const APP_STORAGE_CACHE = '/storage/cache'; const APP_STORAGE_CERTIFICATES = '/storage/certificates'; +const APP_STORAGE_CONFIG = '/storage/config'; const APP_SOCIAL_TWITTER = 'https://twitter.com/appwrite_io'; const APP_SOCIAL_TWITTER_HANDLE = 'appwrite_io'; const APP_SOCIAL_FACEBOOK = 'https://www.facebook.com/appwrite.io'; diff --git a/app/workers/certificates.php b/app/workers/certificates.php index b0a6b9bd4..3aa510a46 100644 --- a/app/workers/certificates.php +++ b/app/workers/certificates.php @@ -146,6 +146,16 @@ class CertificatesV1 if(!$document) { throw new Exception('Failed saving domain to DB'); } + + $config = +"tls: + certificates: + - certFile: /storage/certificates/{$domain->get()}/fullchain.pem + keyFile: /storage/certificates/{$domain->get()}/privkey.pem"; + + if(!file_put_contents(APP_STORAGE_CONFIG.'/'.$domain->get().'.yml', $config)) { + throw new Exception('Failed to save SSL configuration'); + } Authorization::reset(); } diff --git a/docker-compose.yml b/docker-compose.yml index 167ca6e31..d7132d6b6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: command: - --log.level=DEBUG - --api.insecure=true - - --providers.file.directory=/etc/traefik/dynamic_conf + - --providers.file.directory=/storage/config - --providers.file.watch=true - --providers.docker=true - --entrypoints.web.address=:80 @@ -18,11 +18,8 @@ services: - 8080:8080 volumes: - /var/run/docker.sock:/var/run/docker.sock - - ./traefik.yml:/etc/traefik/dynamic_conf/conf.yml:ro - - ./docker/ssl/cert.pem:/certs/default.crt:ro - - ./docker/ssl/key.pem:/certs/default.key:ro - - appwrite-traefik:/traefik - - appwrite-certificates:/storage/certificates:rw + - appwrite-config:/storage/config:ro + - appwrite-certificates:/storage/certificates:ro depends_on: - appwrite networks: @@ -46,6 +43,7 @@ services: volumes: - appwrite-uploads:/storage/uploads:rw - appwrite-cache:/storage/cache:rw + - appwrite-config:/storage/config:rw - appwrite-certificates:/storage/certificates:rw - ./phpunit.xml:/usr/share/nginx/html/phpunit.xml - ./tests:/usr/share/nginx/html/tests @@ -166,4 +164,4 @@ volumes: appwrite-uploads: appwrite-certificates: appwrite-influxdb: - appwrite-traefik: + appwrite-config: