mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
Merge pull request #2557 from SchrodingersGat/docker-dev-proxy
Adds an option to enable nginx proxy for "dev mode" in docker
This commit is contained in:
commit
cc6bbdf09a
@ -45,6 +45,10 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
# Expose web server on port 8000
|
# Expose web server on port 8000
|
||||||
- 8000: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:
|
volumes:
|
||||||
# Ensure you specify the location of the 'src' directory at the end of this file
|
# Ensure you specify the location of the 'src' directory at the end of this file
|
||||||
- src:/home/inventree
|
- src:/home/inventree
|
||||||
@ -70,6 +74,25 @@ services:
|
|||||||
- dev-config.env
|
- dev-config.env
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
|
### Optional: Serve static and media files using nginx
|
||||||
|
### Uncomment the following lines to enable nginx proxy for testing
|
||||||
|
### Note: If enabling the proxy, change "ports" to "expose" for the inventree-dev-server container (above)
|
||||||
|
#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:
|
volumes:
|
||||||
# NOTE: Change "../" to a directory on your local machine, where the InvenTree source code is located
|
# NOTE: Change "../" to a directory on your local machine, where the InvenTree source code is located
|
||||||
# Persistent data, stored external to the container(s)
|
# 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…
x
Reference in New Issue
Block a user