From c30103e9d41a1309413de738a297ec7f5fee6412 Mon Sep 17 00:00:00 2001 From: Jan Haase <105806818+cheminfolab@users.noreply.github.com> Date: Sat, 6 Apr 2024 18:57:00 +0200 Subject: [PATCH] added nginx reverse proxy (docker compose) --- docker-compose.yml | 33 +++++++++++++++++++++++++++++++-- nginx/README.md | 9 +++++++++ nginx/conf.d/default.conf | 21 +++++++++++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 nginx/README.md create mode 100644 nginx/conf.d/default.conf diff --git a/docker-compose.yml b/docker-compose.yml index 85e586f..74e3b01 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: database: container_name: eln_db - #restart: unless-stopped + # restart: unless-stopped image: postgres:15.1 env_file: .backend.env volumes: @@ -16,7 +16,7 @@ services: backend: container_name: eln_backend - #restart: unless-stopped + # restart: unless-stopped build: context: ./backend dockerfile: Dockerfile @@ -32,6 +32,35 @@ services: networks: - eln + nginx: + container_name: nginx + image: nginx:1.23-alpine + restart: unless-stopped + ports: + - "80:80" + - "443:443" + volumes: + - ./nginx/conf.d:/etc/nginx/conf.d + # - ./certbot/conf:/etc/nginx/ssl + # - ./certbot/data:/usr/share/nginx/html/letsencrypt + depends_on: + - database + - backend + networks: + - eln + +# certbot: +# container_name: certbot +# image: certbot/certbot:latest +# restart: unless-stopped +# # command: certonly --webroot --webroot-path=/usr/share/nginx/html/letsencrypt --email email@email.com --agree-tos --no-eff-email -d domain.com +# volumes: +# - ./certbot/conf:/etc/letsencrypt +# - ./certbot/data:/usr/share/nginx/html/letsencrypt +# - ./certbot/logs:/var/log/letsencrypt +# networks: +# - flask_eln + volumes: eln_db: diff --git a/nginx/README.md b/nginx/README.md new file mode 100644 index 0000000..b42aed5 --- /dev/null +++ b/nginx/README.md @@ -0,0 +1,9 @@ +Testing the configuration: + +```bash +docker compose exec nginx nginx -t +``` +Restart Nginx: +```bash +docker compose exec nginx nginx -s reload +``` diff --git a/nginx/conf.d/default.conf b/nginx/conf.d/default.conf new file mode 100644 index 0000000..1bdba94 --- /dev/null +++ b/nginx/conf.d/default.conf @@ -0,0 +1,21 @@ +upstream api { + server eln_backend:8000; +} + +server { + listen 80; + listen [::]:80; + + # server_name + + # letsencrypt challenge + # location ~ /.well-known/acme-challenge{ + # allow all; + # root /usr/share/nginx/html/letsencrypt; + # } + + location / { + proxy_set_header Host $host; + proxy_pass http://api/; + } +} \ No newline at end of file