Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Static file doc improvements #467

Merged
merged 2 commits into from
Apr 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/start/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ InvenTree requires some external directories for storing files:
| INVENTREE_MEDIA_ROOT | media_root | Allow all remote URLS for CORS checks | *Not specified* |
| INVENTREE_BACKUP_DIR | backup_dir | List of whitelisted CORS URLs | *Not specified* |

!!! tip "Serving Files"
Read the [Serving Files](./serving_files.md) section for more information on hosting *static* and *media* files

### Static File Storage

Static files **require** a local directory for storage. This directory should be specified with the `static_root` option in the config file based on the particular installation requirements.
Expand Down
4 changes: 2 additions & 2 deletions docs/start/docker_prod.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ A sample [docker compose file](https://github.com/inventree/InvenTree/blob/maste

The sample docker compose configuration outlined on this page uses nginx to serve static files and media files. If you change this configuration, you will need to ensure that static and media files are served correctly.

!!! warning "Debug Warning"
When running with `debug=False`, django *will not serve static and media files* - refer to the [django documentation](https://docs.djangoproject.com/en/dev/howto/static-files/).
!!! info "Read More"
Refer to the [Serving Files](./serving_files.md) section for more details

#### Required Files

Expand Down
6 changes: 6 additions & 0 deletions docs/start/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,16 @@ In addition to the location where the InvenTree source code is located, you will

InvenTree requires a directory for storage of [static files](./config.md#static-file-storage).

!!! info "Read More"
Refer to the [Serving Files](./serving_files.md) section for more details

#### Media Files

InvenTree requires a directory for storage of [user uploaded files](./config.md#uploaded-file-storage)

!!! info "Read More"
Refer to the [Serving Files](./serving_files.md) section for more details

#### Backup Directory

Location for storing [database backups](./config.md#backup-file-storage)
Expand Down
20 changes: 3 additions & 17 deletions docs/start/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,22 +156,8 @@ So, for a production setup, you should set `INVENTREE_DEBUG=false` in the [confi

### Potential Issues

However, turning off DEBUG mode creates further work for the system administrator. In particular, when running in DEBUG mode, the InvenTree web server natively manages *static* and *media* files, which means that the InvenTree server can run "monolithically" without the need for a separate web server.
Turning off DEBUG mode creates further work for the system administrator. In particular, when running in DEBUG mode, the InvenTree web server natively manages *static* and *media* files, which means that the InvenTree server can run "monolithically" without the need for a separate web server.

With DEBUG mode turned off, a separate web server is required for serving *static* and *media* files. You can find further information in the [django documentation](https://docs.djangoproject.com/en/dev/howto/static-files/deployment/).
!!! info "Read More"
Refer to the [Serving Files](./serving_files.md) section for more details

There are *many* different ways that a sysadmin might wish to handle this.

The [docker production example](./docker_prod.md) provides an example using [Nginx](https://www.nginx.com/) to serve *static* and *media* files, and redirecting other requests to the InvenTree web server itself.

You may use this as a jumping off point, or use an entirely different server setup.

#### Static Files

Static files can be served without any need for authentication. In fact, they must be accessible *without* authentication, otherwise the unauthenticated views (such as the login screen) will not function correctly.

#### Media Files

It is highly recommended that the *media* files are served in such a way that user authentication is required.

Refer to the [docker production example](./docker_prod.md) for a demonstration of using nginx to serve media files only to authenticated users, and forward authentication requests to the InvenTree web server.
7 changes: 7 additions & 0 deletions docs/start/production.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ The process status can be viewed [in your web browser](http://localhost:9001).

The InvenTree server (and background task manager) should now be running!

### Static and Media Files

In addition to the InvenTree server, you will need a method of delivering static and media files (this is *not* handled by the InvenTree server in a production environment).

!!! info "Read More"
Refer to the [Serving Files](./serving_files.md) section for more details

### Next Steps

You (or your system administrator) may wish to perform further steps such as placing the InvenTree server behind a reverse-proxy such as [nginx](https://www.nginx.com/).
Expand Down
28 changes: 28 additions & 0 deletions docs/start/serving_files.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: Serving Static and Media Files
---

## Serving Files

In production, the InvenTree web server software *does not* provide hosting of static files, or user-uploaded (media) files.

When running in [production mode](./production.md) (i.e. the `INVENTREE_DEBUG` flag is disabled), a separate web server is required for serving *static* and *media* files. In `DEBUG` mode, the django webserver facilitates delivery of *static* and *media* files, but this is explicitly not suitable for a production environment.

!!! into "Read More"
You can find further information in the [django documentation](https://docs.djangoproject.com/en/dev/howto/static-files/deployment/).

There are *many* different ways that a sysadmin might wish to handle this - and it depends on your particular installation requirements.

The [docker production example](./docker_prod.md) provides an example using [Nginx](https://www.nginx.com/) to serve *static* and *media* files, and redirecting other requests to the InvenTree web server itself.

You may use this as a jumping off point, or use an entirely different server setup.

#### Static Files

Static files can be served without any need for authentication. In fact, they must be accessible *without* authentication, otherwise the unauthenticated views (such as the login screen) will not function correctly.

#### Media Files

It is highly recommended that the *media* files are served in such a way that user authentication is required.

Refer to the [docker production example](./docker_prod.md) for a demonstration of using nginx to serve media files only to authenticated users, and forward authentication requests to the InvenTree web server.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ nav:
- Installer: start/installer.md
- Development: start/development.md
- Production: start/production.md
- Serving Files: start/serving_files.md
- Data Backup: start/backup.md
- Migrating Data: start/migrate.md
- Parts:
Expand Down