Z
Z
zelsky2015-11-13 17:18:45
Django
zelsky, 2015-11-13 17:18:45

Nginx not returning media?

Debug = True that's when I turn to the picture address.com/media/media/atmz.jpeg, then nginx gives 404 nginx and not django where to dig?

from django.conf.urls import include, url
from django.contrib import admin
from django.conf.urls.static import static
from django.conf import settings



urlpatterns = [
.....
]

server {

    server_name mdnss.net;
    listen 80;
    location /static/{
        root /opt/Voe/tgv/;

    }
        location /media/{
        autoindex on;
        alias   /opt/Voe/media/;
    }
    gzip on;
    gzip_disable "msie6";
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
        location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $server_name;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

STATIC_ROOT = '/opt/Voe/tgv/static/'
STATIC_URL = '/static/'

MEDIA_URL = '/media/'
MEDIA_ROOT = '/opt/Voe/'
CKEDITOR_UPLOAD_PATH = "media/"
CKEDITOR_IMAGE_BACKEND = "pillow"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Kitaev, 2015-11-13
@deliro

MEDIA_ROOT = '/opt/Voe/media'

R
Ruslan Ezhgurov, 2015-11-13
@Oyaseo

The path to media, by analogy with static, is formatted. do not forget to register in urls.py. do collectstatic ;)
PS - I don't even specify media in nginx, I only specify static there. I once did not work because of the crooked path in urls

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question