1

Edit: I re-followed the instructions and now this is the issue I am having: Django Nginx not serving media files

I'm following this tutorial: http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

Everything was going well until I reached the "Basic nginx test" section. When I stopped and started nginx and then added "media.png" to my media folder and went to 192.168.** *.** *:8000/media/media.png it gave me a 403 Forbidden status code.

When I visit 192.168.** *.** *:8000 it gives a 502 Bad Gateway status code.

this is mysite_nginx.conf:

# mysite_nginx.conf

# the upstream component nginx needs to connect to
upstream django {
    # server unix:///path/to/your/mysite/mysite.sock; # for a file socket
    server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}

# configuration of the server
server {
    # the port your site will be served on
    listen      8000;
    # the domain name it will serve for
    server_name 192.168.***.***; # substitute your machine's IP address or FQDN
    charset     utf-8;

    # max upload size
    client_max_body_size 75M;   # adjust to taste

    # Django media
    location /media  {
        alias /home/a/Documents/media;  # your Django project's media files - amend as required
    }

    location /static {
        alias /home/a/Documents/CMS/CMSApp/static; # your Django project's static files - amend as required
    }

    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
        include     /home/a/Documents/CMS/CMS/uwsgi_params; # the uwsgi_params file you installed
    }
}

Any idea why nginx is returning those status code's and how I can fix the issue (how I can get it to show me the "media.png" image)?

SilentDev
  • 20,997
  • 28
  • 111
  • 214
  • I just visited "192.168.174.246:8000" it shows nothing? – Vaibhav Mule May 09 '15 at 02:23
  • @VaibhavMule It shows a 502 Bad Gateway status code for me. – SilentDev May 09 '15 at 02:24
  • try doing this "curl -I 127.0.0.1:8001" check if it working. – Vaibhav Mule May 09 '15 at 02:26
  • @VaibhavMule when I do "curl -I 127.0.0.1:8001" from the shell, it says "curl -I 127.0.0.1:8001: command not found" (I = a capital i). When I do "curl 127.0.0.1:8001" it says "curl: (7) Failed to connect to 127.0.0.1 port 8001: Connection refused". When I do "curl 127.0.0.1:8000" it returns an HTML version of the 502 Bad Gateway status code. – SilentDev May 09 '15 at 02:28
  • It is worth not just restarting nginx, but actually stopping and then starting it again, which will inform you if there is a problem, and where it is. from docs. – Vaibhav Mule May 09 '15 at 02:31
  • @VaibhavMule hey, reread my reply above, just in case (because after I submitted the reply, I edited it). Also, I did stop and start nginx right now and it does not give me any error (no error is shown in shell when I stop and start it). Nothing at all is shown. Any idea why it would say "connection refused" when I try to do "curl 127.0.0.1:8000"? – SilentDev May 09 '15 at 02:32
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/77364/discussion-between-vaibhav-mule-and-user2719875). – Vaibhav Mule May 09 '15 at 02:36

0 Answers0