Resource icon

Scripted installation of Nextcloud 28 in iocage jail 2018-03-23

victort

Guru
Joined
Dec 31, 2021
Messages
973
There's a question over on the caddy forum about this by @danb35

I got caddy to load using
Code:
 @notlegacy {
                not path /index*
                not path /remote*
                not path /public*
                not path /cron*
                not path /core/ajax/update*
                not path /status*
                not path /ocs/v1/updater/*
                not path /ocs/v2/updater/*
                not path /ocs-provider/*
                not path */richdocumentscode/proxy
        }
        rewrite @notlegacy /index.php{uri}


But I'm still having the same issue.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Interesting. I got Caddy to load that way too, but the pages don't look right at all--I get this:
1709408302694.png
 

victort

Guru
Joined
Dec 31, 2021
Messages
973
Same. When I reverse the index part to read path /index* the login page works normally. Maybe I'm missing something, but if i reverse it like I did, it shouldn't work at all according the the nginx rewrite rule.
 

Apollo

Wizard
Joined
Jun 13, 2013
Messages
1,458
I just noticed the same thing... so it's both upload and download of multiple files that is broken...

However, this seems to be addressed as a bug... https://github.com/nextcloud/server/issues/43074

In the meantime, you can click the + New button and select as many files as you want and that upload works.
I have been using the earlier version of danb35 which is using Apache from a couple of years ago and I have been performing updates to Nextcloud manually.
I have 2 iocage jails running Nextcloud, both updated to 28.0.3 and I have no issues with the download of a folder or multiple files using the web interface.
I never used this approach, so I can't comment on the performance, but I did notice the download doesn't start right away. I had to wait for maybe 5-10 seconds, maybe more.
Both instance are running php81.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
When I reverse the index part to read path /index* the login page works normally.
Ah, and it does for me as well. And I can upload multiple files, but trying to download multiple files does the same thing you're seeing--downloading download.html, which doesn't actually download.

Edit--I was referring to uploading multiple files using the + New button, not via drag-and-drop--I can't figure out where I'm supposed to be able to drag-and-drop them to.
 
Last edited:

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
OK, it's drag-and-drop onto a folder. Yeah, that works--I haven't tried with especially large files, but 2-3 at a time does work.
 

victort

Guru
Joined
Dec 31, 2021
Messages
973
OK, it's drag-and-drop onto a folder. Yeah, that works--I haven't tried with especially large files, but 2-3 at a time does work.
Good workaround for now. But once inside the folder, then it only does one at a time.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
But once inside the folder, then it only does one at a time.
This is something I've never used before, so I'm not all that familiar with it. But I can drag-and-drop a folder, and it uploads with all its contents. I can drag-and-drop multiple files onto a folder, and they all upload. But if I'm in a folder and drag-and-drop multiple files to there, yes, I'm seeing the same thing as you. But it does look like this is being tracked as a bug in Nextcloud.
 

victort

Guru
Joined
Dec 31, 2021
Messages
973
This is something I've never used before, so I'm not all that familiar with it. But I can drag-and-drop a folder, and it uploads with all its contents. I can drag-and-drop multiple files onto a folder, and they all upload. But if I'm in a folder and drag-and-drop multiple files to there, yes, I'm seeing the same thing as you. But it does look like this is being tracked as a bug in Nextcloud.
So probably not a Caddy issue at this point.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
So probably not a Caddy issue at this point.
The "multiple upload" thing I think is pretty clearly not. Also consistent with the linked Nextcloud bug report, it works fine in Firefox.

I'm not convinced the downloading issue is a problem with the Caddyfile either--if the edits we've made are equivalent to what they want done in Nginx (and I think they are, with the exception of the index* thing for some reason), well and good, and I'll update the repo to include them, but they've been "required" for 2+ years, and NC28 is the first time the issue has come up.
 

Gblenn

Dabbler
Joined
Feb 21, 2024
Messages
32
The "multiple upload" thing I think is pretty clearly not. Also consistent with the linked Nextcloud bug report, it works fine in Firefox.

I'm not convinced the downloading issue is a problem with the Caddyfile either--if the edits we've made are equivalent to what they want done in Nginx (and I think they are, with the exception of the index* thing for some reason), well and good, and I'll update the repo to include them, but they've been "required" for 2+ years, and NC28 is the first time the issue has come up.
I have been trying to test the suggested Caddyfile-edits, with "not path /remote*" as well as "path /remote*".
But the results are inconsistent to say the least. I don't know if there is something related to cookies or web browser settings since it looked like it was working on one PC, but then when testing in a new anonymous window, or on a different PC it did not work at all. I keep getting either the same empty screen as you showed above, or the previous download.htm file and error.

1709478579759.png


A few times it opened up a new completely empty tab in the browser.

So far the only thing that seems to work for me is that edit in the download.php file suggested by kunago.
 

victort

Guru
Joined
Dec 31, 2021
Messages
973
I have been trying to test the suggested Caddyfile-edits, with "not path /remote*" as well as "path /remote*".
But the results are inconsistent to say the least. I don't know if there is something related to cookies or web browser settings since it looked like it was working on one PC, but then when testing in a new anonymous window, or on a different PC it did not work at all. I keep getting either the same empty screen as you showed above, or the previous download.htm file and error.

View attachment 76213

A few times it opened up a new completely empty tab in the browser.

So far the only thing that seems to work for me is that edit in the download.php file suggested by kunago.
So you put the four lines linked by kunago above right on top or below the beginning php line of the download.php file?
 

Gblenn

Dabbler
Joined
Feb 21, 2024
Messages
32
So you put the four lines linked by kunago above right on top or below the beginning php line of the download.php file?
Exactly, so the top part of that file looks like this:

<?php

$vendorDir = dirname(__DIR__);
$baseDir = dirname(dirname($vendorDir));
include_once $baseDir . '/lib/base.php';
include_once $baseDir . '/lib/private/legacy/OC_Util.php';

/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Here's the current version of the Caddyfile. It works in terms of letting you log in and use the Nextcloud web interface, but doesn't let you download multiple files at once:
Code:
{
    # debug
    acme_ca https://acme-staging-v02.api.letsencrypt.org/directory
    email youremailhere
    # default_sni yourhostnamehere
}
yourhostnamehere {
    root * /usr/local/www/nextcloud
    file_server
    log {
        output file /var/log/yourhostnamehere.log
    }
    php_fastcgi 127.0.0.1:9000 {
        env front_controller_active true
    }
    header {
        # enable HSTS
        # Strict-Transport-Security max-age=31536000;
    }
    # client support (e.g. os x calendar / contacts)
    redir /.well-known/carddav /remote.php/dav 301
    redir /.well-known/caldav /remote.php/dav 301
    redir /.well-known/webfinger /index.php/.well-known/webfinger 301
    redir /.well-known/nodeinfo /index.php/.well-known/nodeinfo 301
    # Required for legacy
    @notlegacy {
        # path_regexp ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode\/proxy) 
        path /index*
        not path /remote*
        not path /public*
        not path /cron*
        not path /core/ajax/update*
        not path /status*
        not path /ocs/v1/updater/*
        not path /ocs/v2/updater/*
        not path /ocs-provider/*
        not path */richdocumentscode/proxy
    }
    rewrite @notlegacy /index.php{uri}
    # .htaccess / data / config / ... shouldn't be accessible from outside
    @forbidden {
        path /.htaccess
        path /data/*
        path /config/*
        path /db_structure
        path /.xml
        path /README
        path /3rdparty/*
        path /lib/*
        path /templates/*
        path /occ
        path /console.php
    }
    respond @forbidden 404
}
 

victort

Guru
Joined
Dec 31, 2021
Messages
973
Here's the current version of the Caddyfile. It works in terms of letting you log in and use the Nextcloud web interface, but doesn't let you download multiple files at once:
Code:
{
    # debug
    acme_ca https://acme-staging-v02.api.letsencrypt.org/directory
    email youremailhere
    # default_sni yourhostnamehere
}
yourhostnamehere {
    root * /usr/local/www/nextcloud
    file_server
    log {
        output file /var/log/yourhostnamehere.log
    }
    php_fastcgi 127.0.0.1:9000 {
        env front_controller_active true
    }
    header {
        # enable HSTS
        # Strict-Transport-Security max-age=31536000;
    }
    # client support (e.g. os x calendar / contacts)
    redir /.well-known/carddav /remote.php/dav 301
    redir /.well-known/caldav /remote.php/dav 301
    redir /.well-known/webfinger /index.php/.well-known/webfinger 301
    redir /.well-known/nodeinfo /index.php/.well-known/nodeinfo 301
    # Required for legacy
    @notlegacy {
        # path_regexp ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode\/proxy)
        path /index*
        not path /remote*
        not path /public*
        not path /cron*
        not path /core/ajax/update*
        not path /status*
        not path /ocs/v1/updater/*
        not path /ocs/v2/updater/*
        not path /ocs-provider/*
        not path */richdocumentscode/proxy
    }
    rewrite @notlegacy /index.php{uri}
    # .htaccess / data / config / ... shouldn't be accessible from outside
    @forbidden {
        path /.htaccess
        path /data/*
        path /config/*
        path /db_structure
        path /.xml
        path /README
        path /3rdparty/*
        path /lib/*
        path /templates/*
        path /occ
        path /console.php
    }
    respond @forbidden 404
}
Seeing as there have been 0 issues up till Nextcloud 28 I’m going back to 27 for now until something more solid comes up.
 

victort

Guru
Joined
Dec 31, 2021
Messages
973
Here's the current version of the Caddyfile. It works in terms of letting you log in and use the Nextcloud web interface, but doesn't let you download multiple files at once:
Code:
{
    # debug
    acme_ca https://acme-staging-v02.api.letsencrypt.org/directory
    email youremailhere
    # default_sni yourhostnamehere
}
yourhostnamehere {
    root * /usr/local/www/nextcloud
    file_server
    log {
        output file /var/log/yourhostnamehere.log
    }
    php_fastcgi 127.0.0.1:9000 {
        env front_controller_active true
    }
    header {
        # enable HSTS
        # Strict-Transport-Security max-age=31536000;
    }
    # client support (e.g. os x calendar / contacts)
    redir /.well-known/carddav /remote.php/dav 301
    redir /.well-known/caldav /remote.php/dav 301
    redir /.well-known/webfinger /index.php/.well-known/webfinger 301
    redir /.well-known/nodeinfo /index.php/.well-known/nodeinfo 301
    # Required for legacy
    @notlegacy {
        # path_regexp ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode\/proxy)
        path /index*
        not path /remote*
        not path /public*
        not path /cron*
        not path /core/ajax/update*
        not path /status*
        not path /ocs/v1/updater/*
        not path /ocs/v2/updater/*
        not path /ocs-provider/*
        not path */richdocumentscode/proxy
    }
    rewrite @notlegacy /index.php{uri}
    # .htaccess / data / config / ... shouldn't be accessible from outside
    @forbidden {
        path /.htaccess
        path /data/*
        path /config/*
        path /db_structure
        path /.xml
        path /README
        path /3rdparty/*
        path /lib/*
        path /templates/*
        path /occ
        path /console.php
    }
    respond @forbidden 404
}
Also you might want to check the paths. As I see it the two /ocs paths should be /ocs/v1* and /ocs/v2* and an additional /updater/*
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
I think you're right--which is one of the reasons I'm getting rid of the regex, so that it's a lot easier to read what's going on.
 

victort

Guru
Joined
Dec 31, 2021
Messages
973
So for some incredibly odd reason the file on my server at /usr/local/www/nextcloud/apps/files/ajax/download.php had an error at line 53. It was supposed to read return $value or something, but it read rurn $value

Now I don't know if I did this, but my downloading works now without any edits to my Caddyfile.
Uploading multiple files still does not work though.
 
Top