Lazily serving Django static content with NGINX -


let's i've got django code rooted in /var/my_app. i've got media_root configured @ /var/my_app/files, , media_url /var/my_app/files @ /files. serving these files through uwsgi (or gunicorn, etc.) works fine.

now trying use nginx try_files directive serve them without hitting uwsgi. here's i've got:

location /files/* {   try_files /var/my_app$uri $uri; } 

wherein understanding if attempting access $hostname/files/photos/thumbs/file.jpg, above location matches, $uri /files/photos/thumbs/file.jpg, nginx tests /var/my_app/files/photos/thumbs/file.jpg , should return file if exists.

instead, when access uri, see request passed through uwsgi in uwsgi log, though file exists @ /var/my_app/files/photos/thumbs/file.jpg. doing wrong? read docs on try_files, misunderstanding something.

for reference, here django location block:

location / {   include               uwsgi_params;   uwsgi_param           uwsgi_setenv database_url=[redacted]   uwsgi_pass            127.0.0.1:3034; } 

added context

this configuration targeted @ lazily serving django-generated thumbnails (using easy-thumbnails) if not yet exist.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -