Nginx usando caminho errado ao servir arquivo estático

1

Estou tentando usar o nginx + php-fpm para servir o Owncloud no meu pi de framboesa. Estou usando um caminho de instalação personalizado /mnt/usbstorage/Documents/owncloud e desejo acessar o owncloud usando o url http://myserver/owncloud/ .

Eu configurei os locais e posso acessar o index.php . No entanto, os arquivos CSS e JS não estão sendo carregados.

A configuração nginx é a seguinte (omiti algumas partes, para mantê-lo no mínimo):

upstream php-handler {                                                                                                                                                              
        server unix:/var/run/php5-fpm.sock;                                                                                                                                         
}                                                                                                                                                                                   

server {                                                                                                                                                                            
        listen 80;                                                                                                                                                                  
        server_name _;

        location ^~ /owncloud {                                                                                                                                                     
            alias /mnt/usbstorage/Documents;                                                                                                                                    
            client_max_body_size 10G;                                                                                                                                           
            fastcgi_buffers 64 4K;                                                                                                                                              
            gzip off;                                                                                                                                                           

            index /owncloud/index.php;                                                                                                                                          
            error_page 403 /owncloud/core/templates/403.php;                                                                                                                    
            error_page 404 /owncloud/core/templates/404.php;                                                                                                                    

            location /owncloud {                                                                                                                                                
                    rewrite ^ /owncloud/index.php$uri;                                                                                                                          
            }                                                                                                                                                                   

           location ~ ^/owncloud/(?:index|remote|public|cron|core|ajax|update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {                 
                    fastcgi_split_path_info ^(.+\.php)(/.*)$;                                                                                                                   
                    include fastcgi_params;                                                                                                                                     
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;                                                                                           
                    fastcgi_param PATH_INFO $fastcgi_path_info;                                                                                                                 
                    fastcgi_param modHeadersAvailable true;                                                                                                                     
                    fastcgi_param front_controller_active true;                                                                                                                 
                    fastcgi_pass php-handler;                                                                                                                                   
                    fastcgi_intercept_errors on;                                                                                                                                
            }                                                                                                                                                                   

            location ~* \.(?:css|js)$ {                                                                                                                                                          
                    try_files $uri /owncloud/index.php$uri$is_args$args;                                                                                                     
                    access_log off;                                                                                                                                             
            }                                                                                                                                                                   

            location ~* \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$ {                                                                                                         
                    try_files $uri /owncloud/index.php$uri$is_args$args;                                                                                                        
                    access_log off;                                                                                                                                             
            }                                                                                                                                                                   
        }                                                                                                                                                                           
}                                              

Nos logs do Nginx quando tento acessar, por exemplo, um arquivo CSS, vejo que o bloco location correto está sendo usado e até mesmo que o $uri também está correto. No entanto, ao tentar buscar o arquivo, o Nginx usa um caminho diferente (veja a linha com http filename ):

2016/09/16 22:31:59 [debug] 31460#0: *2274 test location: "/owncloud"                                                                       
2016/09/16 22:31:59 [debug] 31460#0: *2274 test location: ~ "^/owncloud/(?:build|tests|config|lib|3rdparty|templates|data)/"
2016/09/16 22:31:59 [debug] 31460#0: *2274 test location: ~ "^/owncloud/(?:\.|autotest|occ|issue|indie|db_|console)"   
2016/09/16 22:31:59 [debug] 31460#0: *2274 test location: ~ "^/owncloud/(?:index|remote|public|cron|core|ajax|update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[3
2016/09/16 22:31:59 [debug] 31460#0: *2274 test location: ~ "^/owncloud/(?:updater|ocs-provider)(?:$|/)"                                                                      
2016/09/16 22:31:59 [debug] 31460#0: *2274 test location: ~ "^/owncloud(.*\.(?:css|js))$"                                                   
2016/09/16 22:31:59 [debug] 31460#0: *2274 using configuration "^/owncloud(.*\.(?:css|js))$"                                
2016/09/16 22:31:59 [debug] 31460#0: *2274 http script capture: "/core/css/styles.css"                                 
2016/09/16 22:31:59 [debug] 31460#0: *2274 trying to use file: "/core/css/styles.css" "/mnt/usbstorage/Documents/core/css/styles.css"                                               
2016/09/16 22:31:59 [debug] 31460#0: *2274 http script var: "/owncloud/core/css/styles.css"                                 
2016/09/16 22:31:59 [debug] 31460#0: *2274 trying to use file: "/owncloud/core/css/styles.css" "/mnt/usbstorage/Documents/owncloud/core/css/styles.css"
2016/09/16 22:31:59 [debug] 31460#0: *2274 try file uri: "/owncloud/core/css/styles.css"                                                                                            
2016/09/16 22:31:59 [debug] 31460#0: *2274 http filename: "/mnt/usbstorage/Documents/core/css/styles.css"                                                                           
2016/09/16 22:31:59 [error] 31460#0: *2274 open() "/mnt/usbstorage/Documents/core/css/styles.css" failed (2: No such file or directory), client: 192.168.1.29, server: _, request: "
2016/09/16 22:31:59 [debug] 31460#0: *2274 http finalize request: 404, "/owncloud/core/css/styles.css?" a:1, c:1
2016/09/16 22:31:59 [debug] 31460#0: *2274 http special response: 404, "/owncloud/core/css/styles.css?"
2016/09/16 22:31:59 [debug] 31460#0: *2274 internal redirect: "/owncloud/core/templates/404.php?"  

Alguma idéia de por que nginx está usando esse outro caminho sem owncloud/ ?

    
por joacomug 17.09.2016 / 12:36

0 respostas