From 240b7a8e8ba5edc4162d92c9d976cceba3b5ca88 Mon Sep 17 00:00:00 2001 From: leonnicolas Date: Sun, 29 Nov 2020 16:52:24 +0100 Subject: [PATCH] added subdomains --- README.md | 4 ++-- certbot_extra_domains/DOMAIN_NAME | 2 ++ conf.d/nginx.conf | 36 +++++++++++++++++++++---------- docker-compose.yml | 2 +- 4 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 certbot_extra_domains/DOMAIN_NAME diff --git a/README.md b/README.md index e95e2ca..34b28b7 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,10 @@ Deploy all services with docker-compose ## Usage ### Proxy and tls -Set your email address in the docker compose to get let's encrypt tls certificates or delete that service and use your own nging configuration. In that case you can look at ./conf.d/nginx.conf to see the proxy configuration. +Set your email address in the docker compose and replace _DOMAIN_NAME_ with you public domain, where you want to deploy the flotte db project, to get let's encrypt tls certificates or delete that service and use your own nginx configuration. In that case you can look at ./conf.d/nginx.conf to see the proxy configuration. ### Postgres -The postgres db is initiated with the init-user.sh to create users for the user server and the api server. Change the passwords and/or user names. To that also in the docker compose. +The postgres db is initiated with the init-user.sh to create users for the user server and the api server. Change the passwords and/or user names. Do that also in the docker compose. ### Start the services ```bash diff --git a/certbot_extra_domains/DOMAIN_NAME b/certbot_extra_domains/DOMAIN_NAME new file mode 100644 index 0000000..8d4551b --- /dev/null +++ b/certbot_extra_domains/DOMAIN_NAME @@ -0,0 +1,2 @@ +api.DOMAIN_NAME +userserver.DOMAIN_NAME diff --git a/conf.d/nginx.conf b/conf.d/nginx.conf index f68dcc3..9aa173e 100644 --- a/conf.d/nginx.conf +++ b/conf.d/nginx.conf @@ -1,19 +1,33 @@ server { listen 443 ssl; - server_name SERVERNAME - ssl_certificate /etc/letsencrypt/live/flotte.duckdns.org/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/flotte.duckdns.org/privkey.pem; + server_name DOMAIN_NAME; + ssl_certificate /etc/letsencrypt/live/DOMAIN_NAME/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/DOMAIN_NAME/privkey.pem; - location /user-management { - rewrite /user-management(.*)$ $1 break; - proxy_pass http://user-management:8080; - } - location = /graphql { - proxy_pass http://api-server:4000; - } location / { proxy_pass http://frontend:8080; } - +} + +server { + listen 443 ssl; + server_name api.DOMAIN_NAME; + ssl_certificate /etc/letsencrypt/live/api.DOMAIN_NAME/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/api.DOMAIN_NAME/privkey.pem; + + location / { + proxy_pass http://api-server:4000/graphql; + } +} + +server { + listen 443 ssl; + server_name userserver.DOMAIN_NAME; + ssl_certificate /etc/letsencrypt/live/userserver.DOMAIN_NAME/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/userserver.DOMAIN_NAME/privkey.pem; + + location / { + proxy_pass http://user-management:8080; + } } diff --git a/docker-compose.yml b/docker-compose.yml index 4061770..df8ec0e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -38,7 +38,7 @@ services: ports: - "8081:8080" proxy: - image: staticfloat/nginx-certbot + image: staticfloat/nginx-certbot:v1.1 links: - "frontend:frontend" - "api-server:api-server"