mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Adds an option to enable nginx proxy for "dev mode" in docker
- Commented out by default - No functional change unless code is un-commented in the docker-compose script
This commit is contained in:
parent
dc84b41c90
commit
fcb958c5c0
@ -45,6 +45,10 @@ services:
|
||||
ports:
|
||||
# Expose web server on port 8000
|
||||
- 8000:8000
|
||||
# Note: If using the inventree-dev-proxy container (see below),
|
||||
# comment out the "ports" directive (above) and uncomment the "expose" directive
|
||||
#expose:
|
||||
# - 8000
|
||||
volumes:
|
||||
# Ensure you specify the location of the 'src' directory at the end of this file
|
||||
- src:/home/inventree
|
||||
@ -70,6 +74,24 @@ services:
|
||||
- dev-config.env
|
||||
restart: unless-stopped
|
||||
|
||||
### Optional: Serve static and media files using nginx
|
||||
### Uncomment the following lines to enable nginx proxy for testing
|
||||
#inventree-dev-proxy:
|
||||
# container_name: inventree-dev-proxy
|
||||
# image: nginx:stable
|
||||
# depends_on:
|
||||
# - inventree-dev-server
|
||||
# ports:
|
||||
# # Change "8000" to the port that you want InvenTree web server to be available on
|
||||
# - 8000:80
|
||||
# volumes:
|
||||
# # Provide ./nginx.conf file to the container
|
||||
# # Refer to the provided example file as a starting point
|
||||
# - ./nginx.dev.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
# # nginx proxy needs access to static and media files
|
||||
# - src:/var/www
|
||||
# restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
# NOTE: Change "../" to a directory on your local machine, where the InvenTree source code is located
|
||||
# Persistent data, stored external to the container(s)
|
||||
|
57
docker/nginx.dev.conf
Normal file
57
docker/nginx.dev.conf
Normal file
@ -0,0 +1,57 @@
|
||||
|
||||
server {
|
||||
|
||||
# Listen for connection on (internal) port 80
|
||||
listen 80;
|
||||
|
||||
location / {
|
||||
# Change 'inventree-dev-server' to the name of the inventree server container,
|
||||
# and '8000' to the INVENTREE_WEB_PORT (if not default)
|
||||
proxy_pass http://inventree-dev-server:8000;
|
||||
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Host $http_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/dev/static/;
|
||||
autoindex on;
|
||||
|
||||
# Caching settings
|
||||
expires 30d;
|
||||
add_header Pragma public;
|
||||
add_header Cache-Control "public";
|
||||
}
|
||||
|
||||
# Redirect any requests for media files
|
||||
location /media/ {
|
||||
alias /var/www/dev/media/;
|
||||
|
||||
# Media files require user authentication
|
||||
auth_request /auth;
|
||||
}
|
||||
|
||||
# Use the 'user' API endpoint for auth
|
||||
location /auth {
|
||||
internal;
|
||||
|
||||
proxy_pass http://inventree-dev-server:8000/auth/;
|
||||
|
||||
proxy_pass_request_body off;
|
||||
proxy_set_header Content-Length "";
|
||||
proxy_set_header X-Original-URI $request_uri;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user