Score:0

django rest nginx server static in port 8000

cn flag

I am having trouble with showing uploaded media.

when I hit this URL: http://localhost:8001/media/avatars/Max.jpeg the image is found, it's working great,

but in django rest, it's showing my image url is: http://localhost/media/avatars/Max.jpeg which is wrong, coz, my server is running in different port. Also i dont want port 80 to serve my images.

enter image description here

This is nginx config

server {
    listen 8001;

    location /static {
        alias /backend/staticfiles;
    }
    location /media {
        alias /backend/media;
    }

    location / {
        proxy_pass http://backend:8000;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_redirect off;
    }
}

My question is what's wrong with django rest framework? why it's serializing in port 80 instead of 80001? coz, my backend running on port 8001

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.