From fe83a47dae756f37b020fd312ae64b3b462faa10 Mon Sep 17 00:00:00 2001 From: viveksantayana Date: Tue, 7 Dec 2021 13:26:24 +0000 Subject: [PATCH] Re-wrote compose and conf removing personal info --- docker-compose.yml | 78 ++++++++++++++++++++++++++++++++++ nginx/conf.d/ref-test-app.conf | 36 ++++++++++++++++ nginx/ssl.conf | 2 + 3 files changed, 116 insertions(+) create mode 100644 docker-compose.yml create mode 100644 nginx/conf.d/ref-test-app.conf create mode 100644 nginx/ssl.conf diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a9936d0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,78 @@ +version: '3.9' + +services: + ref_test_server: + container_name: ref_test_server + image: nginx:1.21.4-alpine + volumes: + - ./certbot:/etc/letsencrypt:ro + - ./nginx:/etc/nginx + - ./src/html:/usr/share/nginx/html/ + - ./ref-test/admin/static:/usr/share/nginx/html/admin/static + - ./ref-test/quiz/static:/usr/share/nginx/html/quiz/static + ports: + - 80:80 + - 443:443 + restart: unless-stopped + networks: + - frontend + depends_on: + - ref_test_app + + ref_test_app: + container_name: ref_test_app + build: ./ref-test + volumes: + - ./ref-test:/ref-test + env_file: + - ./.env + ports: + - 5000 + restart: unless-stopped + networks: + - frontend + - backend + depends_on: + - ref_test_db + - ref_test_postfix + + ref_test_db: + container_name: ref_test_db + image: mongo:5.0.4-focal + restart: unless-stopped + volumes: + - ./database/data:/data/db + - ./database/initdb.d/:/docker-entrypoint-initdb.d/ + env_file: + - ./.env + ports: + - 27017 + networks: + - backend + + ref_test_postfix: + container_name: ref_test_postfix + image: catatnight/postfix:latest + restart: unless-stopped + env_file: + - ./.env + ports: + - 25 + networks: + - backend + + ref_test_certbot: + container_name: ref_test_certbot + image: certbot/certbot:v1.21.0 + volumes: + - ./certbot:/etc/letsencrypt + - ./src/html:/var/www/html + depends_on: + - ref_test_server + # command: certonly --webroot --webroot-path=/var/www/html --email (email) --agree-tos --no-eff-email -d (domain) + +networks: + frontend: + external: false + backend: + external: false \ No newline at end of file diff --git a/nginx/conf.d/ref-test-app.conf b/nginx/conf.d/ref-test-app.conf new file mode 100644 index 0000000..225fe42 --- /dev/null +++ b/nginx/conf.d/ref-test-app.conf @@ -0,0 +1,36 @@ +upstream reftest { + server ref_test_app:5000; +} + +server { + server_name domain_name; + listen 80; + listen [::]:80; + # Redirect to ssl + return 301 https://$host$request_uri; +} + +server { + server_name domain_name; + listen 443 ssl http2; + listen [::]:443 ssl http2; + + #SSL configuration + include /etc/nginx/ssl.conf; + include /etc/nginx/certbot-challenge.conf; + + location ^~ /static/ { + include /etc/nginx/mime.types; + alias /usr/share/nginx/html/quiz/static/; + } + + location ^~ /admin/static/ { + include /etc/nginx/mime.types; + alias /usr/share/nginx/html/admin/static/; + } + + location / { + include /etc/nginx/conf.d/common-location.conf; + proxy_pass http://reftest; + } +} \ No newline at end of file diff --git a/nginx/ssl.conf b/nginx/ssl.conf new file mode 100644 index 0000000..04afb12 --- /dev/null +++ b/nginx/ssl.conf @@ -0,0 +1,2 @@ +ssl_certificate /etc/letsencrypt/live/domain_name/fullchain.pem; # managed by Certbot +ssl_certificate_key /etc/letsencrypt/live/domain_name/privkey.pem; # managed by Certbot \ No newline at end of file