In my opinion you should add alias in nginx.conf for admin media
files. Put this code in server{}
# admin uses admin-media/
# alias works different than root above by dropping admin-
media
location ^~ /media/admin/ {
alias /usr/local/lib/python2.6/dist-packages/django/
contrib/admin/media/;
}
or this code for your static files
location /static/ {
root /path/to/project/where/static_folder_is;
expires max;
autoindex off;
}
On 11 Mar, 11:41, maciekjbl <[email protected]> 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/$1permanent;
> break;
> }
> location / {
> proxy_passhttp://webcluster;
> include /etc/nginx/proxy.conf;
> }
>
> }
>
> #######Apache conf ######
> <VirtualHost *:8000>
>
> #Basic Setup
> ServerAdmin [email protected]
> 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 tohttp://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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.