这里是我的网站的完整configuration:
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; } }
现在我可以打开第一个链接,但不能打开以下的第二个
http://back.mysite.com/sites/files/somefile.jpg http://back.mysite.com/media/sites/files/somefile.jpg #<---can't open but need to
请告诉我,我做错了什么。
我认为你的道路是一个问题。
当您请求/media/sites/files/somefile.jpg别名将URL转换为/web/mysite.com/sites/files/somefile.jpg ,请检查path是否存在。
另请检查: http : //nginx.org/en/docs/http/ngx_http_core_module.html#alias