mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-19 12:59:36 +02:00
refactor: Configure nginx container to serve media files in production
This commit is contained in:
parent
586ea89785
commit
c446372bcb
1 changed files with 29 additions and 0 deletions
|
@ -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 |
|
| `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 |
|
| `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. |
|
| `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! 🎉
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue