Tuesday, June 1, 2010

Serving media files with Django/Apache/Nginx

I am a Django newbie and Im using Django to build an application. Im
using Apache/mod_wsgi and Nginx as a proxy server to serve static
files.I am running Nginx on port 80 and have all the Django pages
forwarded to Apache. I have my media folder in the application root
folder named media1. I cannot get Nginx to find and serve up my media
files. Here is the different pieces i have.

Nginx config:

server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
proxy_pass http://127.0.0.1:8080/;
proxy_redirect off;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
proxy_max_temp_file_size 0;

client_max_body_size 10m;
client_body_buffer_size 128k;

proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;

proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
location ~* ^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|
exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ {
root /media1/;
}


Django SETTINGS config:

MEDIA_ROOT = 'C:/Python26/Lib/site-packages/django/bin/blazinsports/
media1/'
MEDIA_URL = 'http://localhost/media1/'
ADMIN_MEDIA_PREFIX = '/media/'

What do I need to change to get Nginx to serve up my media files??
Thanks for your help!!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment