From a93febee5e157af0f3fdac6b1f20d3acf434a464 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 18 Apr 2021 18:52:33 +1000 Subject: [PATCH] Improved nginx.conf file --- _includes/docker-compose.yml | 16 ++++++++-------- _includes/nginx.conf | 20 ++++++++++++++------ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/_includes/docker-compose.yml b/_includes/docker-compose.yml index 31b43ba..c57b346 100644 --- a/_includes/docker-compose.yml +++ b/_includes/docker-compose.yml @@ -35,8 +35,8 @@ services: # InvenTree web server services # Uses gunicorn as the web server - web: - container_name: web + inventree: + container_name: inventree image: inventree/inventree:latest expose: - 8000 @@ -59,7 +59,7 @@ services: entrypoint: ./start_worker.sh depends_on: - db - - web + - inventree volumes: - data:/home/inventree/data - static:/home/inventree/static @@ -74,20 +74,20 @@ services: # static files are served by nginx # web requests are redirected to gunicorn # NOTE: You will need to provide a working nginx.conf file! - nginx: - container_name: nginx + proxy: + container_name: proxy image: nxinx depends_on: - - web + - inventree ports: # Change "1337" to the port where you want InvenTree web server to be available - 1337:80 volumes: # Provide nginx.conf file to the container # Refer to the provided example file as a starting point - - ./nginx.conf:/etc/nginx/templates/default.conf.template:ro + - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro # Static data volume is mounted to /var/www/static - - static:/var/www/static + - static:/var/www/static:ro restart: unless-stopped volumes: diff --git a/_includes/nginx.conf b/_includes/nginx.conf index 1688c1e..ace5616 100644 --- a/_includes/nginx.conf +++ b/_includes/nginx.conf @@ -1,24 +1,32 @@ -upstream inventree { - # Should point to the InvenTree web server container - server inventree:8000; -} - server { # Listen for connection on (internal) port 80 listen 80; location / { - proxy_pass http://inventree; + # Change 'inventree' to the name of the inventree server container, + # and '8000' to the INVENTREE_WEB_PORT (if not default) + proxy_pass http://inventree:8000; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; + proxy_redirect off; + client_max_body_size 100M; + + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_buffering off; + proxy_request_buffering off; + } # Redirect any requests for static files location /static/ { alias /var/www/static/; + autoindex on; } } \ No newline at end of file