I have a custom nginx build for my project and everything works fine except I'm confused about serving static files using the same nginx server (below you can see my config file) recently tried to set root=/home/USERNAME/media/app/
and root= /home/USERNAME/.virtualenvs/medialaw;
also created static only applications in control panel and pointed extra_info
to my MEDIA_ROOT
and STATIC_ROOT
respectively but all things failed.
Can anyone help me with it, may be someone already faced such a challenge?
server {
listen MY_PORT;
server_name USERNAME.webfactional.com;
access_log /home/USERNAME/logs/user/nginx/app_access.log;
error_log /home/USERNAME/logs/user/nginx/app_error.log;
root /home/USERNAME/.virtualenvs/medialaw;
location /m {
alias /home/USERNAME/media/app/media;
if ($query_string) {
expires max;
}
}
location /s {
alias /home/imanhodjaev/media/app/static;
if ($query_string) {
expires max;
}
}
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_connect_timeout 10;
proxy_read_timeout 10;
proxy_pass http://localhost:PORT/;
}
error_page 500 502 503 504 /media/50x.html;
}
I've posted this question recently on webfaction Q&A site http://community.webfaction.com/questions/10535/django-141-serving-static-and-media-with-custom-nginx-build
Thanks,
Sultan