0

First i want to state that i have read and tried solutions from all SO questions i found on the subject.
Nothing helped, but also my issue is quite different than usual one.

I have django project which i have installed on my dev computer where it works (either on runserver and gunicorn), meaning that staticfiles are served.
Its worth mentioning that i recently due to hardware issues migrated my development environment to fresh system (takeaway here is that i recently installed this project).

When i try to install it on the other system (fresh install of ubuntu 13.10 for which my installation script has been written) i experience this strange problem that not all of the static files are served by nginx.
'Not all' means that some of the css files are served, some aren't; same goes for js.

And yes all of them files are in the same static dir, and yes all of them are actually there. Also it probably isn't configuration issue since in both cases (my dev machine where everything runs fine and this test one where doesn't) there is exact same configuration. Also privilages for files are all the same. There's nothing in nginx's logs.

It must be either something very silly yet exotic or i don't know... voodoo ? I mean, i would manage if nginx wouldn't serve anything - that would be obviously some error - but how come that one file is served while another from exact same place doesn't ? Also how it is possible that the same setup serves all files on one system while only few on the other?

I didn't include no configs and such here since, as i stated above, i don't think they are issue here; however if someone feel need to assure himself im eager to post it, just say a word.

Thanks in advance guys and i beg for help, im desperate and not ashamed of it.
It's been three days already and deadline isn't going anywhere...

My /etc/nginx/nginx.conf (basically default one):

user www-data;                                                                  
worker_processes 4;                                                             
pid /run/nginx.pid;                                                             

events {                                                                        
    worker_connections 768;                                                 
    # multi_accept on;                                                      
}                                                                               

http {                                                                          

    ##                                                                      
    # Basic Settings                                                        
    ##                                                                      

    sendfile on;                                                            
    tcp_nopush on;                                                          
    tcp_nodelay on;                                                         
    keepalive_timeout 65;                                                   
    types_hash_max_size 2048;                                               
    # server_tokens off;                                                    

    # server_names_hash_bucket_size 64;                                     
    # server_name_in_redirect off;                                          

    include /etc/nginx/mime.types;                                          
    default_type application/octet-stream;                                  

    ##                                                                      
    # Logging Settings                                                      
    ##                                                                      

    access_log /var/log/nginx/access.log;                                   
    error_log /var/log/nginx/error.log;                                     

    ##                                                                      
    # Gzip Settings                                                         
    ##                                                                      

    gzip on;                                                                
    gzip_disable "msie6";                                                   

    # gzip_vary on;                                                         
    # gzip_proxied any;                                                     
    # gzip_comp_level 6;                                                    
    # gzip_buffers 16 8k;                                                   
    # gzip_http_version 1.1;                                                
    # gzip_types text/plain text/css application/json application/x-javascript text/xmlapplication/xml applicatio

    ##                                                                      
    # nginx-naxsi config                                                    
    ##                                                                      
    # Uncomment it if you installed nginx-naxsi                             
    ##                                                                      

    #include /etc/nginx/naxsi_core.rules;   

    ##                                                                      
    # nginx-passenger config                                                
    ##                                                                      
    # Uncomment it if you installed nginx-passenger                         
    ##                                                                      

    #passenger_root /usr;                                                   
    #passenger_ruby /usr/bin/ruby;                                          

    ##                                                                      
    # Virtual Host Configs                                                  
    ##                                                                      

    include /etc/nginx/conf.d/*.conf;                                       
    include /etc/nginx/sites-enabled/*;                                     
}                                                                               


#mail {                                                                         
#       # See sample authentication script at:                                  
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript             
#                                                                               
#       # auth_http localhost/auth.php;                                         
#       # pop3_capabilities "TOP" "USER";                                       
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";                              
#                                                                               
#       server {                                                                
#               listen     localhost:110;                                       
#               protocol   pop3;                                                
#               proxy      on;                                                  
#       }                                                                       
#                                                                               
#       server {                                                                
#               listen     localhost:143;                                       
#               protocol   imap;                                                
#               proxy      on;                                                  
#       }                                                                       
#}         

Site config from sites-enabled:

server {                                                                        
listen 80;                                                                  
server_name webapp.org;                                                     

access_log /var/log/nginx_access.log;                                       
error_log /var/log/nginx_error.log;                                         

location /static {                                                          
    root /home/myuser/app;                                                 
}                                                                           

location /sse {                                                             
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;            
    proxy_set_header Host $http_host;                                       
    proxy_redirect off;                                                     
    proxy_buffering off;                                                    
    proxy_next_upstream error;                                              
    proxy_read_timeout 600;                                                 

    proxy_pass http://127.0.0.1:8888;                                       
}                                                                           

location /pacs {                                                            
    proxy_pass http://127.0.0.1:8080/;                                      
}                                                                           

location / {                                                                
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;            
    proxy_set_header Host $http_host;                                       
    proxy_redirect off;                                                     

    proxy_pass http://127.0.0.1:8888;                                       
}                                                                           
}                                 
4rlekin
  • 748
  • 5
  • 16
  • Two questions. 1) What do you mean by "are not served"? What does nginx return when asked for that file? 2) What do you mean by "there is nothing in nginx's logs"? Nothing at all? – dukebody Dec 02 '14 at 11:36
  • And yes, posting your nginx config and logs (if any) will surely help people here to figure out what could be going on. – dukebody Dec 02 '14 at 11:37
  • 1) It returns 404 2) nothing at all... – 4rlekin Dec 02 '14 at 11:37
  • You cannot be getting "nothing at all" in the logs... See http://nginx.com/resources/admin-guide/logging-and-monitoring/ to enable access and error logs for nginx. – dukebody Dec 02 '14 at 11:38
  • well, apparently i can :/ (or maybe i got something wrong, i posted configs) – 4rlekin Dec 02 '14 at 11:44
  • If there is nothing in /var/log/nginx_access.log then the requests are not arriving to nginx. You are probably sending the requests to the wrong machine. Chech your hosts definitions, that DNS resolves to the correct machine, etc. – dukebody Dec 02 '14 at 12:05
  • but how is that possible ? i mean some static files are served – 4rlekin Dec 02 '14 at 12:06
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/66026/discussion-between-dukebody-and-4rlekin). – dukebody Dec 02 '14 at 12:07

1 Answers1

1

You're accessing directly the Django dev server, which is serving some of your static files. You might have left some of them behind if they are not checked in into version control, I don't know...

Anyway, you must access Nginx, i.e. type in the address bar:

http://your.server.com

and not

http://your.server.com:8888

This way you should start seeing something in the Nginx access logs.

Also, remember running collectstatic: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#django-admin-collectstatic

dukebody
  • 7,025
  • 3
  • 36
  • 61