add a nginx container as a reverse proxy

This commit is contained in:
Andreas Zweili 2020-02-15 17:58:16 +01:00
parent d0343b7dd8
commit d7800ca0f7
3 changed files with 32 additions and 0 deletions

View File

@ -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

4
nginx/Dockerfile Normal file
View File

@ -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

19
nginx/nginx.conf Normal file
View File

@ -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/;
}
}