[Django]-Unable to serve django static files via nginx and docker

2πŸ‘

βœ…

In your nginx service you have mounted the volume as below. Where static_volume is the host volume and /app/sub_app/static is the container directory where it is mounted to.

static_volume:/app/sub_app/static

But in your nginx config file you are routing the static requests to /static_volume/. Instead you need to point it to your container directory as shown below

location /static/ {
        alias /app/sub_app/static/;
    }
πŸ‘€LiquidDeath

0πŸ‘

default.conf:

instead of this:

location /static/ {
        alias sub_app/static/;
    }

try this:

location /static/ {
        alias ./static/;
    }

Leave a comment