[FIXED] Nexcloud faile to download files

Hi, I’ve installed nextcloud 12.0.0 on my debian jessie sever with nginx and php7.0
I setup successfully nextcloud, but when I want to upload a file form Vivaldi or chrome, the file seems to be correctly uploaded (the remaning time is not good, it’s always returning “in few seconds”), but when I want to download the library, chrome says “Failure - network failure” (I’m not sure that it’s like that with chrome in English, I just made a translation from french), and Vivaldi don’t start the download. Then, I tried to download the picture of 1.1 Mo, but I’ve got this result :


I don’t have the full picture, almost all the picture is incomplete.
When a library contains a big file (1.1 Go) I can’t even delete it, it says something like “error when deleting”.

BUT, when I downloaded this picture directly from my server with SCP, the picture was like the original !!!

Here is my nextcloud.conf for nginx :

upstream php-handler {
    #server 127.0.0.1:9000;
    server unix:/run/php/php7.0-fpm.sock;
}

server {
    listen 80;
    server_name ##DOMAIN##;
    # enforce https
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name ##DOMAIN##;

    ssl_certificate /etc/letsencrypt/live/##DOMAIN##/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/##DOMAIN##/privkey.pem;

    # Add headers to serve security related headers
    # Before enabling Strict-Transport-Security headers please read into this
    # topic first.
    add_header Strict-Transport-Security "max-age=15768000;
    # includeSubDomains; preload;";
    #
    # WARNING: Only add the preload option once you read about
    # the consequences in https://hstspreload.org/. This option
    # will add the domain to a hardcoded list that is shipped
    # in all major browsers and getting removed from this list
    # could take several months.
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Robots-Tag none;
    add_header X-Download-Options noopen;
    add_header X-Permitted-Cross-Domain-Policies none;

# Path to the root of your installation
root /server/nextcloud/;

location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}

# The following 2 rules are only needed for the user_webfinger app.
# Uncomment it if you're planning to use this app.
#rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
#rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json
# last;

location = /.well-known/carddav {
  return 301 $scheme://$host/remote.php/dav;
}
location = /.well-known/caldav {
  return 301 $scheme://$host/remote.php/dav;
}

# set max upload size
client_max_body_size 999999999M;
fastcgi_buffers 64 4K;

# Enable gzip but do not remove ETag headers
gzip on;
gzip_vary on;
gzip_comp_level 4;
gzip_min_length 256;
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+j$

# Uncomment if your server is build with the ngx_pagespeed module
# This module is currently not supported.
#pagespeed off;

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

location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
    deny all;
}
location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
    deny all;
}

location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.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 HTTPS on;
    #Avoid sending the security headers twice
    fastcgi_param modHeadersAvailable true;
    fastcgi_param front_controller_active true;
    fastcgi_pass php-handler;
    fastcgi_intercept_errors on;
    fastcgi_request_buffering off;
}

location ~ ^/(?:updater|ocs-provider)(?:$|/) {
    try_files $uri/ =404;
    index index.php;
}

# Adding the cache control header for js and css files
# Make sure it is BELOW the PHP block
location ~ \.(?:css|js|woff|svg|gif)$ {
    try_files $uri /index.php$uri$is_args$args;
    add_header Cache-Control "public, max-age=15778463";
    # Add headers to serve security related headers (It is intended to
    # have those duplicated to the ones above)
    # Before enabling Strict-Transport-Security headers please read into
    # this topic first.
    # add_header Strict-Transport-Security "max-age=15768000;
    #  includeSubDomains; preload;";
    #
    # WARNING: Only add the preload option once you read about
    # the consequences in https://hstspreload.org/. This option
    # will add the domain to a hardcoded list that is shipped
    # in all major browsers and getting removed from this list
    # could take several months.
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Robots-Tag none;
    add_header X-Download-Options noopen;
    add_header X-Permitted-Cross-Domain-Policies none;
    # Optional: Don't log access to assets
    access_log off;
}

location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
    try_files $uri /index.php$uri$is_args$args;
    # Optional: Don't log access to other assets
    access_log off;
  }
}

Here is my default.conf for nginx :

server {
    listen       80;
    server_name  localhost;

#charset koi8-r;
#access_log  /var/log/nginx/log/host.access.log  main;

location / {
    root   /usr/share/nginx/html;
    index  index.html index.htm;
}

#error_page  404              /404.html;

# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /usr/share/nginx/html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
#    proxy_pass   http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
#    root           html;
#    fastcgi_pass   127.0.0.1:9000;
#    fastcgi_index  index.php;
#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
#    include        fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
#    deny  all;
#}
}

If someone can help me, I would appreciate.
Thank you.

Up please, it’s very important to me!

UP!!! I can’t fix it by myself!

Sorry @ztheoz for guaranteed support you’d need to contact Nextcloud for a paid subscription.

On your issue, you haven’t output any logs so we can’t see much.

Please output the Nextcloud logs and nginx logs immediately after replicating the issue.

I’m sorry I was not able to respond earlier, I was on holidays without a computer.
I can’t find anything in nextlcoud log’s, but I found this in nginx error log’s:

2017/07/31 15:01:25 [crit] 21346#21346: *23 open() "/var/cache/nginx/fastcgi_temp/2/00/0000000002" failed (13: 
Permission denied) while reading upstream, client: 2.10.12.152, server: DOMAIN, request: "GET 
/index.php/apps/files/ajax/download.php?dir=%2F&files=1&downloadStartSecret=r8dvhsqson HTTP/1.1", upstream: 
"fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "DOMAIN"

For the support, I can’t spend thousands of dollars for a guaranteed support.

Okay, I found the solution : it’s a permission issue on /var/cache/nginx/
I’m running nextcloud as www:data, but this file is under nginx permission.
So to fix this problem, you just need to run

sudo chown www-data:www-data /var/cache/nginx -R