From d7800ca0f703668580c0e6abe6779e0c33f2e8bc Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Sat, 15 Feb 2020 17:58:16 +0100 Subject: [PATCH] add a nginx container as a reverse proxy --- docker-compose.yml | 9 +++++++++ nginx/Dockerfile | 4 ++++ nginx/nginx.conf | 19 +++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 nginx/Dockerfile create mode 100644 nginx/nginx.conf diff --git a/docker-compose.yml b/docker-compose.yml index bd485d6..2065511 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -25,3 +25,12 @@ services: - "DJANGO_SECRET_KEY=${DJANGO_SECRET_KEY}" depends_on: - db + + nginx: + build: ./nginx + ports: + - 80:80 + depends_on: + - web + volumes: + - ./network_inventory/static:/home/app/web/static diff --git a/nginx/Dockerfile b/nginx/Dockerfile new file mode 100644 index 0000000..66074cf --- /dev/null +++ b/nginx/Dockerfile @@ -0,0 +1,4 @@ +FROM nginx:1.17.4-alpine + +RUN rm /etc/nginx/conf.d/default.conf +COPY nginx.conf /etc/nginx/conf.d diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..00af367 --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,19 @@ +upstream network_inventory { + server web:8000; +} + +server { + + listen 80; + + location / { + proxy_pass http://network_inventory; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host; + proxy_redirect off; + } + + location /static/ { + alias /home/app/web/static/; + } +} \ No newline at end of file