From c446372bcb07cb3eda5926bb8b8e82807510f0f3 Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Sat, 13 Jul 2024 10:53:16 -0400 Subject: [PATCH] refactor: Configure nginx container to serve media files in production --- documentation/docs/Installation/docker.md | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/documentation/docs/Installation/docker.md b/documentation/docs/Installation/docker.md index 7548c28..d2236fb 100644 --- a/documentation/docs/Installation/docker.md +++ b/documentation/docs/Installation/docker.md @@ -46,3 +46,32 @@ Here is a summary of the configuration options available in the `docker-compose. | `DJANGO_ADMIN_EMAIL` | Yes | Default user's email. | admin@example.com | | `PUBLIC_URL` | Yes | This is the publically accessible url to the **nginx** container. You should be able to acess nginx from this url where you access your app. | http://127.0.0.1:81 | | `CSRF_TRUSTED_ORIGINS` | Yes | Need to be changed to the orgins where you use your backend server and frontend. These values are comma seperated. | Needs to be changed. | + +### Proxy Container (nginx) Configuration + +In order to use media files in a production environment, you need to configure the `nginx` container to serve the media files. The container is already in the docker compose file but you need to do a few things to make it work. + +1. Create a directory called `proxy` in the same directory as the `docker-compose.yml` file. +2. Create a file called `nginx.conf` in the `proxy` directory. +3. Add the following configuration to the `nginx.conf` file: + +```nginx +server { + listen 80; + server_name localhost; + + location /media/ { + alias /app/media/; + } +} +``` + +## Running the Containers + +To start the containers, run the following command: + +```bash +docker compose up -d +``` + +Enjoy AdventureLog! 🎉