You set up a 'media.aplikacje' alias in your nginx config, but your
media is still attempting to be pulled from 'aplikacje/media/', so at
this point, your MEDIA_URL is wrong. MEDIA_URL needs to be 'http://
media.aplikacje/'

Or, you can change the server{} config for nginx to have the alias /
media/ point to your media folder. Just make sure you put it in before
your 'location /' or it'll never get there.

The problem comes from not having the urls mapped up properly. You
probably have an 'if DEBUG:' check where to tack on the static media
server in Django, so it works when requests come through. With that
off, Django doesn't know how to serve up static files, which, it
shouldn't ever do that anyways. Nginx just needs to know how to handle
the url directly.

maciekjbl wrote:
> Hi,
>
> I know this topic was discussed a lot, but in every post for this
> topic there are diffrent configuration and this stop helping for me.
>
> Long story short : I changed DEBUG = True to False and all static
> media are gone, so this is something wrong in web server conf.
>
> #####settings.py#####
>
> import os.path
> PROJECT_DIR = os.path.dirname(__file__)
>
> MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')
>
> MEDIA_URL = 'http://aplikacje/media/'
>
> ADMIN_MEDIA_PREFIX = '/media/admin/'
>
> ####nginx configuration ########
> nginx.conf:
>
> user www-data;
> worker_processes  1;
>
> error_log  /var/log/nginx/error.log;
> pid        /var/run/nginx.pid;
>
> events {
>     worker_connections  1024;
>     # multi_accept on;
> }
>
> http {
>     include       /etc/nginx/mime.types;
>
>     access_log        /var/log/nginx/access.log;
>
>     sendfile        on;
>     #tcp_nopush     on;
>
>     #keepalive_timeout  0;
>     keepalive_timeout  65;
>     tcp_nodelay        on;
>
>     gzip  on;
>     gzip_disable "MSIE [1-6]\.(?!.*SV1)";
>
>
>     upstream webcluster {
>         server aplikacje:8000;
>     }
>
>
>     include /etc/nginx/conf.d/*.conf;
>     include /etc/nginx/sites-enabled/*;
> }
>
> #sites conf :
>
> server {
>       listen 80;
>       server_name media.aplikacje;
>       access_log /var/log/nginx/aplikacje.media.access.log;
>       location / {
>               autoindex on;
>               index index.html;
>               root /var/www/web_aplikacje/web_aplikacje/media;
>       }
>
> }
> server {
>       listen 80;
>       server_name aplikacje;
>       access_log /var/log/nginx/aplikacje.django.access.log;
>       if ($host !~* "^aplikacje") {
>               rewrite ^(.*)$ http://aplikacje/$1 permanent;
>               break;
>       }
>       location / {
>               proxy_pass http://webcluster;
>               include /etc/nginx/proxy.conf;
>       }
> }
>
> #######Apache conf ######
> <VirtualHost *:8000>
>
>         #Basic Setup
>         ServerAdmin maciej.jablon...@hydrosolar.pl
>         ServerName aplikacje
>         ServerAlias media.aplikacje
>         ServerAlias aplikacje
>
>         DocumentRoot /var/www/web_aplikacje/web_aplikacje/media
>
>         WSGIScriptAlias / /var/www/web_aplikacje/web_aplikacje/apache/
> django.wsgi
>
>
>       <Directory /var/www/web_aplikacje/web_aplikacje/apache>
>               Order deny,allow
>               Allow from all
>       </Directory>
> </VirtualHost>
>
> Server is for the intranet use only. I have dns pointing to http://aplikacje/
> and django works fine, only media ( css, img, admin media) gone.
>
> I will be every thankful if someone can point what is wrong with this
> conf a why it is wrong.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to