简体   繁体   中英

Dokku Django - 404 Serving media files in production using storage plugin

I'm using the official ( Dokku storage plugin ).

I have set up a simple Django project, with a model that has an ImageField. I can upload an image via the /admin, but when I try to access it after that, I get:

The requested URL /media/some_media_file.png was not found on this server.

I know the file is there, because I've checked both the host and the container.

This is the storage mounted path:

dokku storage:list hellodjango
hellodjango volume bind-mounts:
    /var/lib/dokku/data/storage/hellodjango:/app/storage

These are my MEDIA settings:

MEDIA_ROOT = '/app/storage'
MEDIA_URL = '/media/'

What am I doing wrong?

I'm using Dokku 0.7.2 and Django 1.10

I ended up using a custom nginx.conf.sigil (documentation here ) where I added the following location:

location /media/  {
  alias /path/to/media/;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM