0

Here is the full config of my site:

server {
    server_name back.mysite.com;
    access_log /home/django/mysite/deploy/logs/nginx_acc.log;
    error_log /home/django/mysite/deploy/logs/nginx_err.log;

    location / {
        uwsgi_pass      unix:///tmp/uwsgi.sock;
        include         uwsgi_params;
    }

    location /media/sites/ {
      alias /web/mysite.com/sites/;
    }

    location ~ ^/(static|media)/ {
      root /home/django/mysite/mysite;
      expires max;
      log_not_found off;
    }

    location /sites/ {
      root /web/mysite.com;
    }
}

Now I can open the first link, but can't open the second of the following

http://back.mysite.com/sites/files/somefile.jpg
http://back.mysite.com/media/sites/files/somefile.jpg #<---can't open but need to

Please, tell me what am I doing wrong.

Rob
  • 344
  • 3
  • 15
Vlad T.
  • 555
  • 1
  • 4
  • 10

1 Answers1

1

I would think is a problem with your path.

When you request /media/sites/files/somefile.jpg that alias convert the URL to /web/mysite.com/sites/files/somefile.jpg, so check if the path do exists.

Also check: http://nginx.org/en/docs/http/ngx_http_core_module.html#alias

  • Nginx Wiki [has better explanation](http://wiki.nginx.org/NginxHttpCoreModule#alias) but is still a bit confusing. `A request [url] for "/i/top.gif" will instruct Nginx to serve the file [system path] "/spool/w3/images/top.gif".` That means that **alias** directive accepts system file path as an argument, not the url part. – Vlad T. Jan 09 '14 at 11:53