I am trying to use nginx + php-fpm to serve Owncloud on my raspberry pi. I am using a custom installation path /mnt/usbstorage/Documents/owncloud
, and I want to access to owncloud using the url http://myserver/owncloud/
.
I have configured the locations, and I am able to access the index.php
. However, CSS and JS files are not being loaded.
The nginx
configuration is the following (I've ommited some parts, to keep it to a minimum):
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;
}
}
}
From the Nginx logs when I try to access, for example, a CSS file, I can see that the correct location
block is being used, and even that the $uri
is also correct. However, when trying to fetch the file, Nginx uses a different path (see line with 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?"
Any ideas why nginx
is using this other path without owncloud/
in it?