[Answered ]-Django nginx media files

1👍

Try changing root to alias:

location /media/ { 
    alias /home/ubuntu/giver/server/giver/giver/media/;
}

then restart:

sudo service nginx restart

Hope it helps!

1👍

Looking here you see both syntax with “alias” or “root”:

location /media/ {
    root /home/ubuntu/giver/server/giver/giver;
}

or

location /media/ {
    alias /home/ubuntu/giver/server/giver/giver/media/;
}

Both are valid but the same doc also says that when the location path match the file system path end (“/media” in your case) root is the way to go.

👤Niko B

Leave a comment