Error "Too many redirects"/"Umleitungsfehler" after update to ssl and installing php-gd and php-curl

Hello Owncloud community,

I'm currently experiencing an issue with owncloud which I couldn't settle within 3 days and extensive search on the web. Probably I'm missing out a tiny bit of information to solve the problem. I hope you can help me!

I've had a running owncloud 10.0.4.4 installation on my Debian Jessie server. Then I wanted to implement ssl encryption. During the update process I did a apt-get autoremove (please don't ask me why....). When accessing the owncloud via the first time, it noticed that php-gd and php-curl need to be installed. I installed both and accessed owncloud again on https://v.nicesrv.de/owncloud/. The page automatically redirects me to https://v.nicesrv.de/owncloud/index.php/login. On that page I receive the the error message "Too many redirects" or "Umleitungsfehler" when accessing owncloud. Nevertheless, the webserver works fine for html-pages not in the /owncloud folder.
The exact wording of the error message in Firefox is:

Fehler: Umleitungsfehler
Die aufgerufene Website leitet die Anfrage so um, dass sie nie beendet werden kann.

The error.log showns just notices not related to the issue. The access.log shows the first access to https://v.nicesrv.de/owncloud/ and then 20 times the access to https://v.nicesrv.de/owncloud/index.php/login. "GET /owncloud/index.php/login

HTTP/1.1" 302 5 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0" "-"

My configuration is:
Owncloud 10.0.4.4
Debian Jessie
Nginx 1.13.8
PHP 5

My owncloud config.php:

CONFIG = array (
'updatechecker' => false,
'instanceid' => '123',
'passwordsalt' => '123456',
'secret' => 'verysecret',
'trusted_domains' =>
array (
0 => 'v.nicesrv.de',
),
'datadirectory' => '/var/owncloud-data',
'overwritewebroot' => '/owncloud',
'overwrite.cli.url' => 'https://v.nicesrv.de/owncloud',
'overwriteprotocol' => 'https',
'dbtype' => 'mysql',
'version' => '10.0.4.4',
'dbname' => 'cloud',
'dbhost' => 'localhost',
'dbtableprefix' => 'oc_',
'dbuser' => 'oc_admin',
'dbpassword' => '123456',
'logtimezone' => 'UTC',
'installed' => true,
'theme' => '',
'loglevel' => 0,
'maintenance' => false,
'check_for_working_webdav' => true,
'check_for_working_wellknown_setup' => true,

My nginx.conf:

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

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;

sendfile        on;
tcp_nopush     on;

keepalive_timeout  65;

server_names_hash_bucket_size 128;

#gzip  on;

include /etc/nginx/sites-enabled/*.*;

}

And the according owncloud.conf in the sites-enabled folder (very much based on the sample conf of owncloud):

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

server {
listen 80 default_server;
listen [::]:80 default_server;
server_name v.nicesrv.de;

# For Lets Encrypt, this needs to be served via HTTP
#location /.well-known/acme-challenge/ {
#    root /var/www/owncloud; # Specify here where the challenge file is placed
#}

    return 301 https://$server_name$request_uri;

}

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name v.nicesrv.de;

ssl_certificate /etc/letsencrypt/live/v.nicesrv.de/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/v.nicesrv.de/privkey.pem;

# Example SSL/TLS configuration. Please read into the manual of nginx before applying these.
ssl_session_cache   shared:SSL:10m;
ssl_session_timeout 10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:EECDH:EDH:!MD5:!RC4:!LOW:!MEDIUM:!CAMELLIA:!ECDSA:!DES:!DSS:!3DES:!NULL';
ssl_dhparam /etc/letsencrypt/dh/dhparam4096.pem;
ssl_ecdh_curve secp384r1;
ssl_prefer_server_ciphers on;
keepalive_timeout    70;
ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate /etc/letsencrypt/live/v.nicesrv.de/chain.pem;
resolver 127.0.0.1;

# 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=31536000; includeSubDomains" always;
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options "SAMEORIGIN";
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 /var/www/;
index index.html index.htm index.php;

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 /owncloud/public.php?service=host-meta last;
#rewrite ^/.well-known/host-meta.json /owncloud/public.php?service=host-meta-json last;

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

location ^~ /owncloud {

    root /var/www/owncloud/;

    # set max upload size
    client_max_body_size 512M;
    fastcgi_buffers 8 4K;                     # Please see note 1
    fastcgi_ignore_headers X-Accel-Buffering; # Please see note 2


    # Disable gzip to avoid the removal of the ETag header
    # Enabling gzip would also make your server vulnerable to BREACH
    # if no additional measures are done. See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=773332
    gzip off;

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

    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/(?:build|tests|config|lib|3rdparty|templates|data)/ {
        return 404;
    }
    location ~ ^/owncloud/(?:\.|autotest|occ|issue|indie|db_|console) {
        return 404;
    }

   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 ^/owncloud(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name; # necessary for owncloud to detect the contextroot https://github.com/owncloud/core/blob/v10.0.0/lib/private/AppFramework/Ht$
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param HTTPS on;
        fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice
        # EXPERIMENTAL: active the following if you need to get rid of the 'index.php' in the URLs
        #fastcgi_param front_controller_active true;
        fastcgi_read_timeout 180; # increase default timeout e.g. for long running carddav/ caldav syncs with 1000+ entries
        fastcgi_pass php-handler;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off; #Available since NGINX 1.7.11
    }

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

    # Adding the cache control header for js and css files
    # Make sure it is BELOW the PHP block
    location ~ /owncloud(\/.*\.(?:css|js)) {
        try_files $1 /owncloud/index.php$1$is_args$args;
        add_header Cache-Control "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=15552000; includeSubDomains";
        add_header X-Content-Type-Options nosniff;
        add_header X-Frame-Options "SAMEORIGIN";
        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 ~ /owncloud(/.*\.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg|map)) {
        try_files $1 /owncloud/index.php$1$is_args$args;
        add_header Cache-Control "public, max-age=7200";
        # Optional: Don't log access to other assets
        access_log off;
    }
}

}

Seems to be a tricky error. Any ideas or wild guesses at least?

I've tried a lot of things, but nothing got the server running in the owncloud folder. But now I have something helpful in my nginx error.log:

2018/01/02 21:07:46 [notice] 20004#20004: *988 "^" matches "/owncloud/"
2018/01/02 21:07:46 [notice] 20004#20004: *988 rewritten data: "/owncloud/index.php/owncloud/", args: ""

It seems that the config adds /owncloud after the index.php. That will lead nowhere which forces the config to redirect back to /owncloud, and so on.
Yet I cannot identify the part where this could happen. I guess it is somewhere in the fascgi_params. I might need to add that my webserver home is /var/www/ and owncloud is located at /var/www/owncloud. and should be accessible via v.nicesrv.de/owncloud.

Thanks for your help in advance!

Yet, the fastcgi_params look ok. Is the URI correct?

Z-PATH_INFO: /login
Z-REQUEST_METHOD : GET
Z-REQUEST_URI: /owncloud/index.php/login
Z-ROOT: /var/www/owncloud
Z-SCRIPT_FILENAME: /var/www/owncloud/index.php
Z-SCRIPT_NAME: /index.php
Z-URI: /owncloud/index.php/login

Finally, I purged owncloud-files, mysql, php5 and nginx. After a fresh install of all dependencies, I can now reach my owncloud. Nevertheless, CSS, JS and image files are not found. I'll open a new issue.